Downloads · 30 days
46
1% of all-time downloads
UniverseTBD/astrollama
astrollama is a text generation model from UniverseTBD. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as mit.
Downloads · 30 days
46
1% of all-time downloads
All-time downloads
5.5K
Public
Parameters
6.7B
80.9 GB on disk
Likes
25
Public
Click a slice to open those files.
.bin27 GB · 50%
From the Hugging Face model README
Play with the model in our Hugging Face space! https://huggingface.co/spaces/universeTBD/astrollama
<p align="center"> <img src="https://huggingface.co/universeTBD/astrollama/resolve/main/images/astrollama-logo.png" alt="AstroLLaMA" width="500px"/> </p>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()