Feature Extraction
Transformers
Safetensors
lemondecider_decision
decision-model
typed-decisions
multimodal
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
Update code/probe_joint.py
Browse files- probe_joint.py +28 -0
probe_joint.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""GPU probe of short and recursive-chunk paths; no benchmark data required."""
|
| 3 |
+
import argparse,copy,json
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
p=argparse.ArgumentParser();p.add_argument('--checkpoint',type=Path,required=True);p.add_argument('--device',default='cuda:0');a=p.parse_args()
|
| 6 |
+
from serve_312k import LemonDeciderHFService
|
| 7 |
+
s=LemonDeciderHFService(a.checkpoint,a.device,None)
|
| 8 |
+
short=json.loads((Path(__file__).resolve().parents[1]/'examples/request.json').read_text())
|
| 9 |
+
long={'state':'Synthetic chunk-planning regression.','questions':{str(i):{'type':'choice','instructions':'Choose one.','criteria':{'a':'alpha '*80,'b':'beta '*80}} for i in range(64)}}
|
| 10 |
+
reports=[]
|
| 11 |
+
for body,split in [(short,False),(long,True)]:
|
| 12 |
+
before=copy.deepcopy(body)
|
| 13 |
+
rows=[{'state':body['state'],'question':q,'images':[]} for q in body['questions'].values()]
|
| 14 |
+
chunks=s.plan(rows)
|
| 15 |
+
assert (len(chunks)>1)==split
|
| 16 |
+
assert [r for c in chunks for r in c]==rows
|
| 17 |
+
assert all(s.joint.unit_lengths(s.processor,s.model.config,[c])[0]<=8192 for c in chunks)
|
| 18 |
+
actual=s.predict(body);answers=[];tokens=0
|
| 19 |
+
for c in chunks:
|
| 20 |
+
result=s.predict_joint(s.model,s.processor,c);answers.extend(result['answers']);tokens+=result['input_tokens']
|
| 21 |
+
assert list(actual['answers'].values())==answers
|
| 22 |
+
assert actual['usage']['input_tokens']==tokens and list(actual['answers'])==list(body['questions'])
|
| 23 |
+
assert body==before
|
| 24 |
+
reports.append({'split':split,'chunk_sizes':[len(c) for c in chunks],'native_per_chunk_parity':True,'input_tokens':tokens})
|
| 25 |
+
try:s.predict({'state':'hello '*20000,'questions':{'q':short['questions']['intent']}})
|
| 26 |
+
except ValueError as e:assert 'exceeds' in str(e) and 'truncated' in str(e)
|
| 27 |
+
else:raise AssertionError('Oversized singleton was not rejected')
|
| 28 |
+
print(json.dumps({'passed':True,'cases':reports,'singleton_rejected':True},indent=2))
|