Feature Extraction
Transformers
Safetensors
lemondecider_decision
decision-engine
typed-decision
choice
classification
Merge
qwen3.5
custom_code
Instructions to use inclusionAI/LemonDecider with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use inclusionAI/LemonDecider with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="inclusionAI/LemonDecider", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("inclusionAI/LemonDecider", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload model.py with huggingface_hub
Browse files
model.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
"""Standalone local decision inference (not an AIStudio Maya canvas component).
|
| 2 |
|
| 3 |
Inside the exported checkpoint this file can be run directly with --checkpoint .
|
| 4 |
-
The actual HF architecture lives in
|
| 5 |
"""
|
| 6 |
import argparse
|
| 7 |
import json
|
| 8 |
from pathlib import Path
|
| 9 |
import torch
|
| 10 |
-
from transformers import AutoModel
|
| 11 |
|
| 12 |
if Path(__file__).with_name('decision_utils.py').is_file():
|
| 13 |
from decision_utils import predict_batch, answer_codes
|
|
@@ -22,11 +22,17 @@ def load_model(checkpoint, device='cuda:0'):
|
|
| 22 |
model = AutoModel.from_pretrained(str(checkpoint), trust_remote_code=True,
|
| 23 |
local_files_only=True, dtype=torch.bfloat16, device_map=device,
|
| 24 |
attn_implementation='sdpa').eval()
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
if codes != model.config.codes or ids != model.config.token_ids:
|
| 29 |
raise ValueError('Checkpoint code/tokenizer mapping mismatch')
|
|
|
|
|
|
|
| 30 |
return model, processor
|
| 31 |
|
| 32 |
|
|
|
|
| 1 |
"""Standalone local decision inference (not an AIStudio Maya canvas component).
|
| 2 |
|
| 3 |
Inside the exported checkpoint this file can be run directly with --checkpoint .
|
| 4 |
+
The actual HF architecture lives in modeling_lemondecider.py/configuration_lemondecider.py.
|
| 5 |
"""
|
| 6 |
import argparse
|
| 7 |
import json
|
| 8 |
from pathlib import Path
|
| 9 |
import torch
|
| 10 |
+
from transformers import AutoModel
|
| 11 |
|
| 12 |
if Path(__file__).with_name('decision_utils.py').is_file():
|
| 13 |
from decision_utils import predict_batch, answer_codes
|
|
|
|
| 22 |
model = AutoModel.from_pretrained(str(checkpoint), trust_remote_code=True,
|
| 23 |
local_files_only=True, dtype=torch.bfloat16, device_map=device,
|
| 24 |
attn_implementation='sdpa').eval()
|
| 25 |
+
if Path(__file__).with_name('decision_utils.py').is_file():
|
| 26 |
+
from decision_utils import load_processor
|
| 27 |
+
else:
|
| 28 |
+
from modeling.decision_utils import load_processor
|
| 29 |
+
processor = load_processor(checkpoint)
|
| 30 |
+
codes, ids = answer_codes(processor.tokenizer, model.config.max_options,
|
| 31 |
+
getattr(model.config, 'code_scheme', 'letters-v1'))
|
| 32 |
if codes != model.config.codes or ids != model.config.token_ids:
|
| 33 |
raise ValueError('Checkpoint code/tokenizer mapping mismatch')
|
| 34 |
+
if tuple(model.readout.weight.shape) != (len(codes), model.config.text_config.hidden_size):
|
| 35 |
+
raise ValueError('Checkpoint readout/code-table shape mismatch')
|
| 36 |
return model, processor
|
| 37 |
|
| 38 |
|