Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Load the model and tokenizer
5tokenizer = AutoTokenizer.from_pretrained("AstroMLab/astrollama-2-7b-base_abstract")
6model = AutoModelForCausalLM.from_pretrained("AstroMLab/astrollama-2-7b-base_abstract", device_map="auto")
7
8# Create the pipeline with explicit truncation
9from transformers import pipeline
10generator = pipeline(
11 "text-generation",
12 model=model,
13 tokenizer=tokenizer,
14 device_map="auto",
15 truncation=True,
16 max_length=512
17)
18
19# Example prompt from an astronomy paper
20prompt = "In this letter, we report the discovery of the highest redshift, " \
21 "heavily obscured, radio-loud QSO candidate selected using JWST NIRCam/MIRI, " \
22 "mid-IR, sub-mm, and radio imaging in the COSMOS-Web field. "
23
24# Set seed for reproducibility
25torch.manual_seed(42)
26
27# Generate text
28generated_text = generator(prompt, do_sample=True)
29print(generated_text[0]['generated_text'])| Model | Score (%) |
|---|---|
| AstroSage-LLaMA-3.1-8B (AstroMLab) | 80.9 |
| AstroLLaMA-2-70B (AstroMLab) | 76.0 |
| LLaMA-3.1-8B | 73.7 |
| Gemma-2-9B | 71.5 |
| Qwen-2.5-7B | 70.4 |
| Yi-1.5-9B | 68.4 |
| InternLM-2.5-7B | 64.5 |
| Mistral-7B-v0.3 | 63.9 |
| ChatGLM3-6B | 50.4 |
| AstroLLaMA-2-7B-AIC | 44.3 |
| AstroLLaMA-2-7B-Abstract | 43.5 |
@ARTICLE{2023arXiv230906126D,
author = {{Dung Nguyen}, Tuan and {Ting}, Yuan-Sen and {Ciuc{\u{a}}}, Ioana and {O'Neill}, Charlie and {Sun}, Ze-Chang and {Jab{\l}o{\'n}ska}, Maja and {Kruk}, Sandor and {Perkowski}, Ernest and {Miller}, Jack and {Li}, Jason and {Peek}, Josh and {Iyer}, Kartheik and {R{\'o}{\.z}a{\'n}ski}, Tomasz and {Khetarpal}, Pranav and {Zaman}, Sharaf and {Brodrick}, David and {Rodr{\'\i}guez M{\'e}ndez}, Sergio J. and {Bui}, Thang and {Goodman}, Alyssa and {Accomazzi}, Alberto and {Naiman}, Jill and {Cranney}, Jesse and {Schawinski}, Kevin and {UniverseTBD}},
title = "{AstroLLaMA: Towards Specialized Foundation Models in Astronomy}",
journal = {arXiv e-prints},
keywords = {Astrophysics - Instrumentation and Methods for Astrophysics, Astrophysics - Cosmology and Nongalactic Astrophysics, Astrophysics - Astrophysics of Galaxies, Astrophysics - High Energy Astrophysical Phenomena, Computer Science - Computation and Language, Computer Science - Machine Learning},
year = 2023,
month = sep,
eid = {arXiv:2309.06126},
pages = {arXiv:2309.06126},
doi = {10.48550/arXiv.2309.06126},
archivePrefix = {arXiv},
eprint = {2309.06126},
primaryClass = {astro-ph.IM},
adsurl = {https://ui.adsabs.harvard.edu/abs/2023arXiv230906126D},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}