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_aic")
6model = AutoModelForCausalLM.from_pretrained("AstroMLab/astrollama-2-7b-base_aic", 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{2024RNAAS...8....7P,
author = {{Perkowski}, Ernest and {Pan}, Rui and {Nguyen}, Tuan Dung and {Ting}, Yuan-Sen and {Kruk}, Sandor and {Zhang}, Tong and {O'Neill}, Charlie and {Jablonska}, Maja and {Sun}, Zechang and {Smith}, Michael J. and {Liu}, Huiling and {Schawinski}, Kevin and {Iyer}, Kartheik and {Ciuc{\u{a}}}, Ioana and {UniverseTBD}},
title = "{AstroLLaMA-Chat: Scaling AstroLLaMA with Conversational and Diverse Datasets}",
journal = {Research Notes of the American Astronomical Society},
keywords = {Astronomy software, Publicly available software, Astronomical instrumentation, 1855, 1864, 799, Astrophysics - Instrumentation and Methods for Astrophysics, Astrophysics - Cosmology and Nongalactic Astrophysics, Astrophysics - Astrophysics of Galaxies, Astrophysics - Solar and Stellar Astrophysics, Computer Science - Computation and Language, Computer Science - Machine Learning},
year = 2024,
month = jan,
volume = {8},
number = {1},
eid = {7},
pages = {7},
doi = {10.3847/2515-5172/ad1abe},
archivePrefix = {arXiv},
eprint = {2401.01916},
primaryClass = {astro-ph.IM},
adsurl = {https://ui.adsabs.harvard.edu/abs/2024RNAAS...8....7P},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}