RuntimeError: probability tensor contains either `inf`, `nan` or element < 0
My code below returns (RuntimeError: probability tensor contains either inf
, nan
or element < 0) :
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("amazon/LightGPT")
model = AutoModelForCausalLM.from_pretrained("amazon/LightGPT")
from transformers import pipeline, TextStreamer
from langchain.llms import HuggingFacePipeline
import torch
streamer = TextStreamer(tokenizer, skip_prompt=True)
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
max_length=3000,
top_p=0,
repetition_penalty=1.15,
streamer=streamer
)
llm = HuggingFacePipeline(pipeline=pipe)
create the chain to answer questions
chain_type_kwargs = {"prompt": PROMPT}
chain = RetrievalQA.from_chain_type(llm=llm, chain_type="stuff", retriever=retriever, chain_type_kwargs=chain_type_kwargs, return_source_documents=True)
Could you please report the full Python stack trace? How long is the PROMPT (in terms of len(PROMPT) or token/word count)?
Also, I was wondering if you replace "max_length=3000" with "max_length=2048", will the same error persist? thanks
Any update on this issue