-
-
Couldn't load subscription status.
- Fork 7
Open
Description
I'm trying to define a simple custom logits processor but the library doesn't seem to support it:
from transformers_js_py import import_transformers_js, LogitsProcessor
transformers = await import_transformers_js()
model_id = "onnx-community/Qwen2.5-0.5B-Instruct"
AutoTokenizer = transformers.AutoTokenizer
tokenizer = await AutoTokenizer.from_pretrained(model_id)
AutoModelForCausalLM = transformers.AutoModelForCausalLM
model = await AutoModelForCausalLM.from_pretrained(model_id)
text = "Example text is here"
inputs = tokenizer(text)
custom_processor = LogitsProcessor()
outputs = await model.generate(
**inputs,
logits_processor=[custom_processor],
)it gives me the following error:
/lib/python3.11/site-packages/pygments/style.py:96: RuntimeWarning: coroutine 'LazyImportTjsProxy.__call__' was never awaited
for styledef in obj.styles.get(token, '').split():
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
---------------------------------------------------------------------------
JsException Traceback (most recent call last)
Cell In[10], line 21
17 inputs = tokenizer(text)
19 custom_processor = LogitsProcessor()
---> 21 outputs = await model.generate(
22 **inputs,
23 logits_processor=[custom_processor],
24 )
File /lib/python311.zip/pyodide/webloop.py:112, in PyodideFuture.then.<locals>.callback(fut)
110 try:
111 if e:
--> 112 r = onrejected_(e)
113 else:
114 r = onfulfilled_(fut.result())
File /lib/python311.zip/pyodide/webloop.py:106, in PyodideFuture.then.<locals>.onrejected_(x)
105 def onrejected_(x):
--> 106 raise x
JsException: TypeError: t is not a function
What am I doing wrong?
Metadata
Metadata
Assignees
Labels
No labels