UniverseTBD/arxiv-astro-abstracts-all
Viewer β’ Updated β’ 326k β’ 10 β’ 5
How to use UniverseTBD/astrollama with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="UniverseTBD/astrollama") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("UniverseTBD/astrollama")
model = AutoModelForCausalLM.from_pretrained("UniverseTBD/astrollama")How to use UniverseTBD/astrollama with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "UniverseTBD/astrollama"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "UniverseTBD/astrollama",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/UniverseTBD/astrollama
How to use UniverseTBD/astrollama with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "UniverseTBD/astrollama" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "UniverseTBD/astrollama",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "UniverseTBD/astrollama" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "UniverseTBD/astrollama",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use UniverseTBD/astrollama with Docker Model Runner:
docker model run hf.co/UniverseTBD/astrollama
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("UniverseTBD/astrollama")
model = AutoModelForCausalLM.from_pretrained("UniverseTBD/astrollama")Play with the model in our Hugging Face space! https://huggingface.co/spaces/universeTBD/astrollama
from transformers import AutoModelForCausalLM
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained(
pretrained_model_name_or_path="universeTBD/astrollama"
)
model = AutoModelForCausalLM.from_pretrained(
pretrained_model_name_or_path="universeTBD/astrollama",
device_map="auto",
)
import torch
from transformers import pipeline
generator = pipeline(
task="text-generation",
model=model,
tokenizer=tokenizer,
device_map="auto"
)
# Taken from https://arxiv.org/abs/2308.12823
prompt = "In this letter, we report the discovery of the highest redshift, " \
"heavily obscured, radio-loud QSO candidate selected using JWST NIRCam/MIRI, " \
"mid-IR, sub-mm, and radio imaging in the COSMOS-Web field. "
# For reproducibility
torch.manual_seed(42)
generated_text = generator(
prompt,
do_sample=True,
max_length=512
)
texts = [
"Abstract 1",
"Abstract 2"
]
inputs = tokenizer(
texts,
return_tensors="pt",
return_token_type_ids=False,
padding=True,
truncation=True,
max_length=4096
)
inputs.to(model.device)
outputs = model(**inputs, output_hidden_states=True)
# Last layer of the hidden states. Get average embedding of all tokens
embeddings = outputs["hidden_states"][-1][:, 1:, ...].mean(1).detach().cpu().numpy()
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="UniverseTBD/astrollama")