Instructions to use vikp/instruction_following_rater with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use vikp/instruction_following_rater with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="vikp/instruction_following_rater")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("vikp/instruction_following_rater") model = AutoModelForSequenceClassification.from_pretrained("vikp/instruction_following_rater", device_map="auto") - Notebooks
- Google Colab
- Kaggle
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Binary classifier to rate how well an input/output pair follows instructions.
Need to format examples like this:
def render_prompts(ex, key):
system = ex.get("system")
rendered = ""
if system and len(system.strip()) > 0:
rendered = rendered + f"### System:\n{system}\n"
if 'input' in ex and 'instruction' not in ex:
ex['instruction'] = ex['input']
del ex['input']
if 'instruction' in ex:
rendered += f"\n### Instruction:\n{ex['instruction']}\n"
if 'input' in ex and len(ex['input'].strip()) > 0:
rendered += f"\n### Input:\n{ex['input']}\n"
rendered += f"\n### Output:\n{ex['output']}"
return {key: rendered.strip()}
Then inference like this:
with torch.no_grad():
pred = model(**tokenized)
logits = pred.logits.cpu().detach()
labels = torch.argmax(logits, dim=1)
probs = F.softmax(logits.to(torch.float32), dim=1)[:,-1]
Labels are 0/1, probs are 0-1.
- Downloads last month
- 4