Transformers · unknown
publisher-documented, not executed source
pip install "transformers>=5.3.0"
from transformers import AutoModelForCausalLM, AutoTokenizer
olmo = AutoModelForCausalLM.from_pretrained("allenai/Olmo-Hybrid-7B")
tokenizer = AutoTokenizer.from_pretrained("allenai/Olmo-Hybrid-7B")
message = ["Language modeling is "]
inputs = tokenizer(message, return_tensors='pt', return_token_type_ids=False)
# optional verifying cuda
# inputs = {k: v.to('cuda') for k,v in inputs.items()}
# olmo = olmo.to('cuda')
response = olmo.generate(**inputs, max_new_tokens=100, do_sample=True, top_k=0, temperature=1.0, top_p=0.7)
print(tokenizer.batch_decode(response, skip_special_tokens=True)[0])
>> 'Language modeling is a fundamental task in natural language processing (NLP) that involves predicting the next word in a sequence given
the previous words. It has been widely used in various NLP applications such as machine translation, speech recognition, and text
generation...'Prerequisites: transformers>=5.3.0; quote version constraint in shell toavoidredirection.
- Base completion model; no final hybrid chat/RL checkpoint is listed.
- 24 DeltaNet layers need recurrent state; 8 full attention layers grow with context.