ariG23498 HF Staff commited on
Commit
c25d338
·
verified ·
1 Parent(s): 41b5294

Upload lightonai_LightOnOCR-2-1B_1.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. lightonai_LightOnOCR-2-1B_1.txt +37 -0
lightonai_LightOnOCR-2-1B_1.txt ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ```CODE:
2
+ # Load model directly
3
+ from transformers import AutoProcessor, AutoModelForSeq2SeqLM
4
+
5
+ processor = AutoProcessor.from_pretrained("lightonai/LightOnOCR-2-1B")
6
+ model = AutoModelForSeq2SeqLM.from_pretrained("lightonai/LightOnOCR-2-1B")
7
+ messages = [
8
+ {
9
+ "role": "user",
10
+ "content": [
11
+ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
12
+ {"type": "text", "text": "What animal is on the candy?"}
13
+ ]
14
+ },
15
+ ]
16
+ inputs = processor.apply_chat_template(
17
+ messages,
18
+ add_generation_prompt=True,
19
+ tokenize=True,
20
+ return_dict=True,
21
+ return_tensors="pt",
22
+ ).to(model.device)
23
+
24
+ outputs = model.generate(**inputs, max_new_tokens=40)
25
+ print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
26
+ ```
27
+
28
+ ERROR:
29
+ Traceback (most recent call last):
30
+ File "/tmp/lightonai_LightOnOCR-2-1B_10E2kMg.py", line 27, in <module>
31
+ model = AutoModelForSeq2SeqLM.from_pretrained("lightonai/LightOnOCR-2-1B")
32
+ File "/tmp/.cache/uv/environments-v2/ee91f5fd6c657f04/lib/python3.13/site-packages/transformers/models/auto/auto_factory.py", line 607, in from_pretrained
33
+ raise ValueError(
34
+ ...<2 lines>...
35
+ )
36
+ ValueError: Unrecognized configuration class <class 'transformers.models.mistral3.configuration_mistral3.Mistral3Config'> for this kind of AutoModel: AutoModelForSeq2SeqLM.
37
+ Model type should be one of BartConfig, BigBirdPegasusConfig, BlenderbotConfig, BlenderbotSmallConfig, EncoderDecoderConfig, FSMTConfig, GPTSanJapaneseConfig, GraniteSpeechConfig, LEDConfig, LongT5Config, M2M100Config, MarianConfig, MBartConfig, MT5Config, MvpConfig, NllbMoeConfig, PegasusConfig, PegasusXConfig, PLBartConfig, ProphetNetConfig, Qwen2AudioConfig, SeamlessM4TConfig, SeamlessM4Tv2Config, SwitchTransformersConfig, T5Config, T5GemmaConfig, UMT5Config, VoxtralConfig, XLMProphetNetConfig.