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:
| Component | Specification | Description |
|---|---|---|
| Parameters | 136 Million | Optimized for high-speed inference and edge deployment. |
| Architecture | Transformer-Decoder | Causal modeling for generative tasks. |
| Layers | 12 | Depth optimized for complex syntactic reasoning. |
| Attention Heads | 12 | Multi-head self-attention for global context capture. |
| Hidden Size | 768 | Balanced representational capacity. |
| Context Window | 1024 Tokens | Sufficient for long-form document processing. |
| Activation | GELU (Approximate) | Modern non-linearity for smoother gradient flow. |
| Tokenizer | DictaLM 2.0 | Optimized for Hebrew morphology and sub-word efficiency. |
๐ 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 ($\beta_1=0.9, \beta_2=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:
- Downloads last month
- 3,050
