Text Classification
Transformers
ONNX
Safetensors
English
reflex_decision
feature-extraction
dual-encoder
multiple-choice
dynamic-labels
research
custom_code
reflex
Eval Results (legacy)
Instructions to use gai-labs/reflex-1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use gai-labs/reflex-1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="gai-labs/reflex-1", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("gai-labs/reflex-1", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download example.py from gai-labs/reflex-1: direct link, hf CLI and curl.
- Browser
- Download file 1.66 kB
-
https://huggingface.co/gai-labs/reflex-1/resolve/main/example.py
- Command line
-
hf download hf://gai-labs/reflex-1/example.py
-
curl -L -o example.py https://huggingface.co/gai-labs/reflex-1/resolve/main/example.py
1.66 kB
| """Download Reflex-1 and exercise single-request and batch inference.""" | |
| import argparse | |
| import json | |
| from dataclasses import asdict | |
| import torch | |
| from transformers import AutoModel | |
| def main(): | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--model", default="gai-labs/reflex-1") | |
| parser.add_argument("--revision", help="Explicit Hub checkpoint branch, tag or commit") | |
| parser.add_argument("--local-files-only", action="store_true") | |
| args = parser.parse_args() | |
| torch.set_num_threads(1) | |
| model = AutoModel.from_pretrained(args.model, trust_remote_code=True, | |
| revision=args.revision, local_files_only=args.local_files_only) | |
| requests = [ | |
| {"state": "The lamp is red.", "question": "Which color is the lamp?", | |
| "options": ["red", "blue", "green"]}, | |
| {"state": "The customer was charged twice for one card payment.", | |
| "question": "Choose the matching issue.", | |
| "options": ["duplicate charge", "lost card", "unknown fee", "cash withdrawal"]}, | |
| ] | |
| single = model.predict(requests[0])[0] | |
| batch = model.predict_batch(requests) | |
| assert single.choice == "red" | |
| assert [decisions[0].choice for decisions in batch] == ["red", "duplicate charge"] | |
| torch.testing.assert_close(torch.tensor(single.probabilities), | |
| torch.tensor(batch[0][0].probabilities), atol=2e-5, rtol=1e-4) | |
| print(json.dumps({"passed": True, "revision": getattr(model.config, "_commit_hash", None), | |
| "decisions": [asdict(row[0]) for row in batch]}, indent=2)) | |
| if __name__ == "__main__": | |
| main() | |