Downloads · 30 days
24
6% of all-time downloads
ronmasas/Hebrew-Mistral-7B-Instruct-v0.1
Hebrew-Mistral-7B-Instruct-v0.1 is a text generation model from ronmasas. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
This is my attempt at instruction tuning for Hebrew-Mistral-7B.
Downloads · 30 days
24
6% of all-time downloads
All-time downloads
416
Public
Parameters
7.5B
15 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors15 GB · 100%
From the Hugging Face model README
This is my attempt at instruction tuning for Hebrew-Mistral-7B.
The model hallucinates a lot. Please generate 4-5 times for each prompt to find the best generation.
Also, note that this model does not have any moderation mechanisms.
Install dependencies
pip install -q -U transformers
pip install accelerate
pip install -q sentencepiece
pip install protobuf
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, StoppingCriteria, TextStreamer
model_id = "ronmasas/Hebrew-Mistral-7B-Instruct-v0.1"
# Load model and tokenizer
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="cuda:0")
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = model.half()
# Define special tokens
END_TOKEN = 64003 # -> [END]
B_INST, E_INST = "[INST]", "[/INST]"
SYSTEM_PROMPT = "A conversation between a human and an AI assistant."
class EosListStoppingCriteria(StoppingCriteria):
def __init__(self, eos_sequence = [END_TOKEN]):
self.eos_sequence = eos_sequence
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
last_ids = input_ids[:,-len(self.eos_sequence):].tolist()
return self.eos_sequence in last_ids
def stream(user_prompt):
prompt = f"{SYSTEM_PROMPT} {B_INST} {user_prompt.strip()} {E_INST}\n"
inputs = tokenizer([prompt], return_tensors="pt").to("cuda:0")
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
_ = model.generate(**inputs, streamer=streamer, max_new_tokens=256, temperature=0.7, do_sample=True, stopping_criteria = [EosListStoppingCriteria()])
stream("כתוב מכתב תודה ל-ים פלג על כך שאימן ושיחרר את המודל Hebrew Mistral 7B.")
"""
הי ים,
אני רוצה להודות לך מקרב לב על העבודה הקשה שהשקעת בדגם Hebrew Mistral 7B. המודל שלך הוא יצירת מופת של למידת מכונה ואני אסיר תודה על הזמן והכישרון שהושקעו בפיתוחו. היכולת להתאמן על שפה באמצעות פלטפורמה כה מתקדמת ומושכת הייתה משב רוח מרענן ומועיל ביותר עבור הקהילה כולה. תודה על כל העבודה הקשה והחזון שהושקעה בפרויקט זה, הוא באמת מאיר עיניים ומשפיע.
שוב תודה מקרב לב,
[שמך]
"""
stream("מה זה ארנונה?")
"""
ארנונה, הידועה גם בשם מס ארנונה, היא מס שנגבה על ידי רשות מקומית (עיר, מחוז או אזור) עבור שירותים מונציפליים שהיא מספקת, כגון חינוך, בריאות ושירותים. זה יכול לכלול מיסים על הכנסה, רכוש ושירותים (כגון מים).
"""
stream("כתוב שלוש כותרות לבלוג על חשיבות איסוף צואה של בעלי חיים.")
"""
1. שמירת תזונה מאוזנת של חיות מחמד באמצעות איסוף צואה
2. השפעות בריאותיות ארוכות טווח של סירוב איסוף צואה של חיות מחמד
3. כיצד איסוף צואה של חיות מחמד עוזר לשמר היגיינה ובריאות בעלי חיים גלובלית.
"""