Views
No views yet
Intelligence, Distilled.
5f19bec6)1# Example: Running your Sovereign Model
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_id = "Rahidul2006/smolified-recipe-ingridient-extractar"
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
7
8messages = [
9 {"role": "system", "content": '''Extract ingredients from Indian recipe instructions into an alphabetical Python list.'''},
10 {"role": "user", "content": '''Prepare Baingan Bharta by roasting a large eggplant directly over an open flame until the skin is charred. Peel the skin and mash the pulp. In a kadhai, heat mustard oil, add cumin seeds, and sauté chopped onions, ginger, and green chilies. Mix in diced tomatoes and cook until soft. Add the mashed eggplant, red chili powder, turmeric, and salt. Cook for 5 minutes and stir in fresh coriander.'''}
11]
12text = tokenizer.apply_chat_template(
13 messages,
14 tokenize = False,
15 add_generation_prompt = True,
16)
17if "gemma-3-270m" == "gemma-3-270m":
18 text = text.removeprefix('<bos>')
19
20from transformers import TextStreamer
21_ = model.generate(
22 **tokenizer(text, return_tensors = "pt").to(model.device),
23 max_new_tokens = 1000,
24 temperature = 1.0, top_p = 0.95, top_k = 64,
25 streamer = TextStreamer(tokenizer, skip_prompt = True),
26)