Views
No views yet

| Component | Specification | Description |
|---|---|---|
| Parameters | 136 Million | Optimized for edge deployment and real-time inference. |
| Architecture | Decoder-only Transformer | Enhanced for causal reasoning and fluency. |
| Layers / Heads | 12 / 12 | Deep representation for nuanced semantics. |
| Context Window | 1024 Tokens | Supports creative long-form generation. |
| Tokenizer | DictaLM 2.0 | High-efficiency sub-word tokenization for Hebrew/English. |
| Training Phase | Post-5 Epoch Instruct | Refined for instruction-following & EOS consistency. |
Note: Due to its training on the C4 corpus, the model retains a vast "general knowledge" base, allowing it to act as a sophisticated creative partner rather than a purely technical agent.
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4MODEL_ID = "TopAI-1/Duchifat-2-Instruct"
5
6def run_duchifat_chat():
7 print("--- Loading Duchifat-2 (Post 5-Epoch Instruct Training) ---")
8
9 tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
10 model = AutoModelForCausalLM.from_pretrained(
11 MODEL_ID,
12 trust_remote_code=True,
13 torch_dtype=torch.bfloat16,
14 device_map="auto"
15 )
16 model.eval()
17 model.config.use_cache = False
18
19 chat_history = []
20
21 print("--- Model Ready! ---")
22
23 while True:
24 user_input = input("\nהכנס הוראה (או 'יציאה'): ")
25 if user_input.lower() in ["exit", "quit", "יציאה"]:
26 break
27
28 # Add current instruction to memory
29 chat_history.append(f"Instruction: {user_input}")
30
31 # Build prompt with history
32 full_prompt = "\n".join(chat_history) + "\nContent:"
33
34 inputs = tokenizer(full_prompt, return_tensors="pt").to(model.device)
35
36 # Context Window Protection (Max 1024 tokens)
37 if inputs.input_ids.shape[1] > 850:
38 chat_history = chat_history[2:] # Trim oldest turn
39 full_prompt = "\n".join(chat_history) + "\nContent:"
40 inputs = tokenizer(full_prompt, return_tensors="pt").to(model.device)
41
42 with torch.no_grad():
43 output_tokens = model.generate(
44 input_ids=inputs.input_ids,
45 attention_mask=inputs.attention_mask,
46 max_new_tokens=300, # Increased for creative writing
47 do_sample=True,
48 temperature=0.75,
49 top_p=0.9,
50 repetition_penalty=1.15,
51 pad_token_id=tokenizer.eos_token_id,
52 use_cache=False
53 )
54
55 full_text = tokenizer.decode(output_tokens[0], skip_special_tokens=True)
56
57 # Extract only the latest response
58 parts = full_text.split("Content:")
59 answer = parts[-1].strip()
60
61 # Save response to history for context
62 chat_history.append(f"Content: {answer}")
63
64 print(f"\nדוכיפת-2: {answer}")
65
66if __name__ == "__main__":
67 run_duchifat_chat()