Raziel1234/Duchifat-2
language:
- he
- en license: apache-2.0 library_name: transformers tags:
- causal-lm
- duchifat
- pytorch-lightning
- hebrew-llm
- bilingual datasets:
- allenai/c4 metrics:
- perplexity ---

🚀 Duchifat-V2 (דוכיפת 2) | Official Model Card
📝 Executive Summary
Duchifat-V2 is a state-of-the-art 136M parameter causal language model (LLM) developed by TopAI. Architected from the ground up, Duchifat-V2 is specifically engineered to bridge the gap between Semitic linguistic structures and modern generative AI. By utilizing a custom-tailored tokenizer and a bilingual training strategy, the model achieves high-performance text generation in both Hebrew and English.
🏗️ Technical Specifications & Architecture
Duchifat-V2 implements a high-efficiency Decoder-only Transformer architecture with the following parameters:
📊 Training Infrastructure & Dataset
1. Data Composition
The model underwent rigorous training on a curated version of the C4 (Colossal Clean Crawled Corpus), distributed as follows:
- Hebrew (50%): High-quality web data, news, and academic sources.
- English (50%): General knowledge base for cross-lingual transfer learning.
2. Compute & Framework
- Compute: NVIDIA L4 / A100 Tensor Core GPUs.
- Orchestration: PyTorch Lightning (v2.x).
- Optimization: AdamW ($\beta1=0.9, \beta2=0.95$).
- Precision: 16-bit Mixed Precision (O2) for memory efficiency.
- Training Steps: ~50,000 Global Steps.
- Effective Batch Size: 64 (via Gradient Accumulation).
🎯 Key Performance Indicators (KPIs)
- Native Hebrew Fluency: Superior understanding of Hebrew grammar compared to general-purpose multilingual models of similar size.
- Zero-Shot Potential: Demonstrated ability to handle basic logic and continuation tasks without fine-tuning.
- Bilingual Versatility: Seamlessly handles code-switching and bilingual contexts.
💻 Implementation & Inference
Model Loading
Since Duchifat-V2 uses a custom architecture, ensure the model class (DuchifatCore) is defined in your environment:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
# --- הגדרות ---
model_id = "Raziel1234/Duchifat-2"
device = "cuda" if torch.cuda.is_available() else "cpu"
print(" טוען את Duchifat-2: הופך למחולל בלוגים יצירתי...")
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
base_model = AutoModelForCausalLM.from_pretrained(
model_id,
trust_remote_code=True,
torch_dtype=torch.bfloat16
).to(device)
if not hasattr(base_model.config, "num_hidden_layers"):
base_model.config.num_hidden_layers = 12
base_model.eval()
def generate_blog_post(topic_title, language="en"):
"""
פונקציה ליצירת פוסט לבלוג.
היא בונה פתיח שגורם למודל להיכנס למוד של כתיבת תוכן.
"""
if language == "he":
prompt = f"פוסט חדש בבלוג: {topic_title}\nהיום אני רוצה לדבר על נושא מרתק שמעסיק אותי רבות. "
else:
prompt = f"Blog Post: {topic_title}\nIn today's post, I want to share some unique insights about {topic_title}. This journey began when "
inputs = tokenizer(prompt, return_tensors="pt").to(device)
with torch.no_grad():
outputs = base_model.generate(
**inputs,
max_new_tokens=250, # אורך של פוסט מכובד
do_sample=True,
temperature=0.8, # יצירתיות גבוהה לבלוג
top_p=0.92,
repetition_penalty=1.2,
no_repeat_ngram_size=3, # מונע חזרתיות מעצבנת
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.eos_token_id
)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
# --- הרצת בדיקה: יצירת בלוגים ---
print("\n" + "="*40)
print(" כתיבת פוסטים לבלוג (Duchifat-2 Base):")
print("="*40)
# בדיקה 1: בלוג טכנולוגי באנגלית
print(" Blog 1 (English - AI Tech):")
blog_en = generate_blog_post("The Future of AI in Daily Life")
print(blog_en)
print("-" * 30)
# בדיקה 2: בלוג סגנון חיים בעברית
print(" בלוג 2 (עברית - לייף סטייל):")
blog_he = generate_blog_post("החשיבות של זמן איכות עם עצמך", language="he")
print(blog_he)import requests
import sys
import io
# תיקון עברית לווינדוס
if sys.platform == "win32":
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
URL = "https://rnevo2016--duchifat-2-ultra-fast-streaming-fastapi-app.modal.run/v1/stream"
# מכיוון שזה מודל BASE - תן לו התחלה של משפט (השלמה)
payload = {
"prompt": "There is something magical about waking up in a city you’ve never visited before. This morning in Rome, the smell of fresh espresso and warm cornetti drifted through the open window of my small Airbnb. As I stepped out onto the cobblestone streets, I realized that the best way to see this city isn't by following a map, but by getting lost in its narrow alleys. My first stop was a tiny bakery where I discovered that",
"temperature": 0.5, # נמוך = יותר ממוקד, גבוה = יותר יצירתי
"repetition_penalty": 1.4, # עוזר למנוע לופים של אתרי חדשות
"max_new_tokens": 300
}
print("דוכיפת מזרימה נתונים בזמן אמת...\n")
try:
with requests.post(URL, json=payload, stream=True) as r:
r.raise_for_status()
for line in r.iter_lines():
if line:
decoded = line.decode('utf-8')
if decoded.startswith("data: "):
# חילוץ הטוקן והדפסה מיידית
token = decoded.replace("data: ", "")
print(token, end="", flush=True)
except Exception as e:
print(f"\nError: {e}")
print("\n" + "="*30)Official App:
Go to: https://duchifat-2-474222140307.us-west1.run.app
