Comments (6)
okay I am checking it
from langchain.
Can you please share your code and prompt as well and the output which shows how the stop word is not working?
from langchain.
Because I double checked the code, everything seems to be functional.
from langchain.
Because I double checked the code, everything seems to be functional.
When specifying stops in the config and calling the list of stop tokens does not work, because in this case the stop list will be None in generate params (see code above in description issue)
generation_config = {
'temperature':0.01,
'top_p':0.9,
'top_k':30,
'max_tokens':1024,
'repetition_penalty':1.1,
'stop': ['.']
}
llm = VLLM(model=llm_name, dtype='float16', **generation_config)
llm.invoke('question')
if we do that
llm.invoke('question', stop=['...'])
it works.
For the same reason, if we run, for example, rag_chain stop list don't work
rag_chain = (
{"context": retriever, "question": RunnablePassthrough()}
| prompt
| llm
| StrOutputParser()
)
from langchain.
No it won't be None because when you pass stop
to the instance of VLLM
i.e during the initialization, the self.stop
is passed to the VLLM client by using the _default_params
attribute. This is passed here, so it cannot be None regardless of whether you pass the stop
during initialization or during invoking.
from langchain.
No it won't be None because when you pass
stop
to the instance ofVLLM
i.e during the initialization, theself.stop
is passed to the VLLM client by using the_default_params
attribute. This is passed here, so it cannot be None regardless of whether you pass thestop
during initialization or during invoking.
if do like this stop token won't work in current _generate implementation
generation_config = {
'temperature':0.01,
'top_p':0.9,
'top_k':30,
'max_tokens':1024,
'repetition_penalty':1.1,
'stop': ['.']
}
llm = VLLM(model=llm_name, dtype='float16', **generation_config)
SYSTEM = "You are an astronomer scientist. Explain step by step"
question = "How does the Moon differ from Earth?"
template = [{"role": "system", "content": f"{SYSTEM}"},
{"role": "user", "content": "Вопрос: {}".format(question)}]
llm_tokenizer = AutoTokenizer.from_pretrained(llm_name)
prompt = llm_tokenizer.apply_chat_template(template, tokenize=False, add_generation_prompt=True)
llm.invoke(prompt)
---------------------
ANSWER:
The Moon and Earth are two celestial bodies that are closely related yet distinct in many ways. Here's a step-by-step explanation of the main differences between them:
1. **Origin**: The Moon is thought to have formed about 4.5 billion years ago, shortly after the formation of the Earth. One theory is that the Moon was created when a massive object collided with the Earth, causing debris to be thrown into orbit and eventually coalesce into the Moon.
2. **Size and Mass**: The Moon is significantly smaller than Earth. It has a diameter of about 3,474 kilometers (2,159 miles), which is about one-quarter of Earth's diameter. The Moon's mass is about one-eighteenth of Earth's mass.
and so on.
Check #15921
"""In the line params = {**self._default_params, **kwargs, "stop": stop}, the "stop" parameter from the "_default_params" method is overwritten by the local "stop" parameter. If no "stop" parameter is passed to the "_generate" method, it defaults to None, effectively ignoring the "stop" parameter set in the VLLM class"""
from langchain.
Related Issues (20)
- [FEATURE REQUEST] langchain-openai - max_tokens (vs max_context?) ability to use full LLM contexts and account for user-messages automatically. HOT 2
- with_structured_output format depends on whether we're using pydantic proper or pydantic.v1 namespace HOT 2
- hunyuan message include chinese signature error
- DOC: <Issue related to /v0.2/docs/tutorials/sql_qa/> HOT 1
- ChatGoogleGenerativeAI does not support streaming HOT 2
- ChatHuggingFace using local model with HuggingFacePipeline wrongly checks for available inference endpoints HOT 1
- I am getting this error HOT 4
- Prepare for pydantic 2 migration by refactoring vanilla @root_validator() usage
- DOC: <Issue related to /v0.2/docs/tutorials/rag/> HOT 11
- Add Document ID back to AzureSearch Documents HOT 1
- Spec out API for all required vs. all possible input variables HOT 1
- RedisChatMessageHistory encountering issues in Redis standalone mode on Windows.
- Standardize DocumentLoader docstrings and integration docs
- Standardize DocumentLoader docstrings and integration do HOT 1
- When using langchain-community, some PDF images will report errors during OCR
- [E:onnxruntime:Default, env.cc:228 ThreadMain] pthread_setaffinity_np failed for thread: 8353, index: 0, mask: {1, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set.
- RPC error: [create_index], <MilvusException: (code=1100, message=create index on 104 field is not supported: invalid parameter[expected=supported field][actual=create index on 104 field])>, <Time:{'RPC start': '2024-06-14 13:38:35.242645', 'RPC error': '2024-06-14 13:38:35.247294'}> HOT 1
- DOC: <Issue related to /v0.2/docs/integrations/chat/> Ollama JSON mode seems to be marked incorrectly as NO HOT 1
- MistralAI Extraction How-To (with examples) throws an error HOT 2
- Wrong spell in DOC: <Issue related to /v0.2/docs/how_to/streaming/>
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from langchain.