Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add temperature to ChatOpenAI #2152

Merged

Conversation

shotat
Copy link
Contributor

@shotat shotat commented Mar 29, 2023

Just add temperature parameter to ChatOpenAI class.

https://python.langchain.com/en/latest/getting_started/getting_started.html#building-a-language-model-application-chat-models
There are descriptions like chat = ChatOpenAI(temperature=0) in the documents, but it is confusing because it is not supported as an explicit parameter.

@shotat shotat marked this pull request as ready for review March 29, 2023 16:34
Copy link
Contributor

@hwchase17 hwchase17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@agola11 agola11 merged commit 09085c3 into langchain-ai:master Mar 29, 2023
@nbrustein
Copy link

I don't think this fix is actually working to pass the temperature to ChatGPT. I ran the following code, and it shows that when I use model_kwargs={'temperature': 0} I get much more consistent responses than when I use temperature=0

from langchain.chat_models import ChatOpenAI
from langchain.chains import LLMChain
from langchain import PromptTemplate



results1 = []
llm = ChatOpenAI(model_kwargs={'temperature': 0})
c = LLMChain(llm=llm, prompt=PromptTemplate(input_variables=["q"], template="{q}"))
for i in range(10):
    print('.')
    results1.append(c.run(q="If I asked you to describe Cleveland, would you give me the same answer every time?"))
    
    
results2 = []
llm = ChatOpenAI(temperature=0)
c = LLMChain(llm=llm, prompt=PromptTemplate(input_variables=["q"], template="{q}"))
for i in range(10):
    results2.append(c.run(q="If I asked you to describe Cleveland, would you give me the same answer every time?"))


results1.sort()
results2.sort()

for r in results1:
    print(r)
    
print('------------------------')
for r in results2:
    print(r)

Output:

As an AI language model, I do not have personal opinions or experiences, so my answer would be consistent. However, the description of Cleveland may vary depending on the source or the person describing it.
As an AI language model, I do not have personal opinions or experiences, so my description of Cleveland would be consistent and based on factual information. However, the level of detail and specific aspects mentioned may vary depending on the context and purpose of the description.
As an AI language model, I do not have personal opinions or experiences, so my description of Cleveland would be consistent and based on factual information. However, the level of detail and specific aspects mentioned may vary depending on the context and purpose of the description.
As an AI language model, I do not have personal opinions or experiences, so my description of Cleveland would be consistent and based on factual information. However, the level of detail and specific aspects mentioned may vary depending on the context and purpose of the description.
As an AI language model, I do not have personal opinions or experiences, so my description of Cleveland would be consistent and based on factual information. However, the level of detail and specific aspects mentioned may vary depending on the context and purpose of the description.
As an AI language model, I do not have personal opinions or experiences, so my description of Cleveland would be consistent and based on factual information. However, the level of detail and specific aspects mentioned may vary depending on the context and purpose of the description.
As an AI language model, I do not have personal opinions or experiences, so my description of Cleveland would be consistent and based on factual information. However, the level of detail and specific aspects mentioned may vary depending on the context and purpose of the description.
As an AI language model, I do not have personal opinions or experiences, so my description of Cleveland would be consistent and based on factual information. However, the level of detail and specific aspects mentioned may vary depending on the context and purpose of the description.
As an AI language model, I do not have personal opinions or experiences, so my description of Cleveland would be consistent and based on factual information. However, the level of detail and specific aspects mentioned may vary depending on the context and purpose of the description.
As an AI language model, I do not have personal opinions or experiences, so my description of Cleveland would be consistent and based on factual information. However, the level of detail and specific aspects mentioned may vary depending on the context and purpose of the description.
------------------------
As an AI language model, I do not have personal experiences or feelings, and every time you ask me to describe Cleveland, I will provide the same factual answer based on the information available to me. However, depending on the specific type of information or perspective you request, my answer may vary slightly.
As an AI language model, I do not have personal experiences, therefore I would provide the same answer every time I am asked to describe Cleveland based on the information available to me. However, my description may vary depending on the specifics of the question or the focus of the description requested.
As an AI language model, I don't have personal opinions or experiences, so my descriptions of Cleveland would be consistent and based on factual information. However, I could describe different aspects of Cleveland depending on the information provided or the context of the query.
As an AI language model, I don't have personal views or impressions. Therefore, my response would be the same every time unless specifically programmed to give different descriptions at different times. However, I can generate different descriptions of Cleveland based on various sources and provide you with general information about the city.
As an AI language model, my descriptions of Cleveland would be consistent in terms of the information available to me. However, my responses may vary depending on the particular details, emphasis, or context of each request.
As an AI language model, my responses are generated based on patterns and associations in vast amounts of text data. Therefore, while my general description of Cleveland may be similar, my responses can vary based on the particular information and language used to prompt me.
As an AI language model, my responses are generated based on the input given to me. Therefore, if you asked me to describe Cleveland multiple times, my response might not be exactly the same each time unless you provide the same input every time. However, I can provide a general description of Cleveland as a city located in northeastern Ohio, along the shores of Lake Erie, and known for its industrial and cultural heritage.
As an AI language model, my responses are not based on personal experiences or biases, so I could provide similar descriptions of Cleveland based on the same inputs. However, if the inputs are different or I am given additional information to work with, my responses could also differ.
Yes, as an AI language model, I should provide consistent responses to the same prompt every time. However, my response would be based on data and information available to me and may not always be comprehensive or up-to-date.
Yes, as an AI language model, my answers are consistent and based on the information available to me. However, different people may have different opinions and perceptions of Cleveland, resulting in varied descriptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants