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

Removed the temperature parameter #657

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions src/ragas/llms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,11 @@ class BaseRagasLLM(ABC):
def set_run_config(self, run_config: RunConfig):
self.run_config = run_config

def get_temperature(self, n: int) -> float:
"""Return the temperature to use for completion based on n."""
return 0.3 if n > 1 else 1e-8

@abstractmethod
def generate_text(
self,
prompt: PromptValue,
n: int = 1,
temperature: float = 1e-8,
stop: t.Optional[t.List[str]] = None,
callbacks: Callbacks = [],
) -> LLMResult:
Expand All @@ -69,7 +64,6 @@ async def agenerate_text(
self,
prompt: PromptValue,
n: int = 1,
temperature: float = 1e-8,
stop: t.Optional[t.List[str]] = None,
callbacks: Callbacks = [],
) -> LLMResult:
Expand All @@ -79,7 +73,6 @@ async def generate(
self,
prompt: PromptValue,
n: int = 1,
temperature: float = 1e-8,
stop: t.Optional[t.List[str]] = None,
callbacks: Callbacks = [],
is_async: bool = True,
Expand All @@ -92,7 +85,6 @@ async def generate(
return await agenerate_text_with_retry(
prompt=prompt,
n=n,
temperature=temperature,
stop=stop,
callbacks=callbacks,
)
Expand All @@ -103,7 +95,6 @@ async def generate(
generate_text_with_retry,
prompt=prompt,
n=n,
temperature=temperature,
stop=stop,
callbacks=callbacks,
)
Expand All @@ -130,23 +121,19 @@ def generate_text(
self,
prompt: PromptValue,
n: int = 1,
temperature: float = 1e-8,
stop: t.Optional[t.List[str]] = None,
callbacks: t.Optional[Callbacks] = None,
) -> LLMResult:
temperature = self.get_temperature(n=n)
if is_multiple_completion_supported(self.langchain_llm):
return self.langchain_llm.generate_prompt(
prompts=[prompt],
n=n,
temperature=temperature,
stop=stop,
callbacks=callbacks,
)
else:
result = self.langchain_llm.generate_prompt(
prompts=[prompt] * n,
temperature=temperature,
stop=stop,
callbacks=callbacks,
)
Expand All @@ -160,23 +147,19 @@ async def agenerate_text(
self,
prompt: PromptValue,
n: int = 1,
temperature: float = 1e-8,
stop: t.Optional[t.List[str]] = None,
callbacks: t.Optional[Callbacks] = None,
) -> LLMResult:
temperature = self.get_temperature(n=n)
if is_multiple_completion_supported(self.langchain_llm):
return await self.langchain_llm.agenerate_prompt(
prompts=[prompt],
n=n,
temperature=temperature,
stop=stop,
callbacks=callbacks,
)
else:
result = await self.langchain_llm.agenerate_prompt(
prompts=[prompt] * n,
temperature=temperature,
stop=stop,
callbacks=callbacks,
)
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ def llm(self):
return self

def generate_text(
self, prompt: PromptValue, n=1, temperature=1e-8, stop=None, callbacks=[]
self, prompt: PromptValue, n=1, stop=None, callbacks=[]
):
generations = [[Generation(text=prompt.prompt_str)] * n]
return LLMResult(generations=generations)

async def agenerate_text(
self, prompt: PromptValue, n=1, temperature=1e-8, stop=None, callbacks=[]
self, prompt: PromptValue, n=1, stop=None, callbacks=[]
):
return self.generate_text(prompt, n, temperature, stop, callbacks)
return self.generate_text(prompt, n, stop, callbacks)


@pytest.fixture
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/llms/test_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ def llm(self):
return self

def generate_text(
self, prompt: PromptValue, n=1, temperature=1e-8, stop=None, callbacks=[]
self, prompt: PromptValue, n=1, stop=None, callbacks=[]
):
generations = [[Generation(text=prompt.prompt_str)] * n]
return LLMResult(generations=generations)

async def agenerate_text(
self, prompt: PromptValue, n=1, temperature=1e-8, stop=None, callbacks=[]
self, prompt: PromptValue, n=1, stop=None, callbacks=[]
):
return self.generate_text(prompt, n, temperature, stop, callbacks)
return self.generate_text(prompt, n, stop, callbacks)
Loading