Instructions to use reciprocate/mistral-7b-rm with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use reciprocate/mistral-7b-rm with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="reciprocate/mistral-7b-rm")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("reciprocate/mistral-7b-rm") model = AutoModelForSequenceClassification.from_pretrained("reciprocate/mistral-7b-rm", device_map="auto") - Notebooks
- Google Colab
- Kaggle
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
model_path = "reciprocate/mistral-7b-rm"
model = AutoModelForSequenceClassification.from_pretrained(model_path)
tokenizer = AutoTokenizer.from_pretrained(model_path)
reward_fn = pipeline("text-classification", model=model, tokenizer=tokenizer, truncation=True, batch_size=8, max_length=4096, device=0)
chats = [[
{"role": "user", "content": "When was the battle at Waterloo?"},
{"role": "assistant", "content": "I think it was in 1983, but please double-check that when you have a chance."}
], [
{"role": "user", "content": "When was the battle at Waterloo?"},
{"role": "assistant", "content": "The battle at Waterloo took place on June 18, 1815."}
]]
output = reward_fn([tokenizer.apply_chat_template(chat, tokenize=False) for chat in chats])
scores = [x["score"] for x in output]
scores
>>> [0.2586347758769989, 0.6663259267807007]
# optionally normalize with the mean and std computed on the training data
scores = (np.array(scores) - 2.01098) / 1.69077
- Downloads last month
- 2