-
Notifications
You must be signed in to change notification settings - Fork 791
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
Making custom LLMs compatible with TestsetGenerator? #230
Comments
I got things working by just running I have set the |
Hey @Data-drone , can you share the ragas & python version you're using? |
ragas==0.0.18 python 3.10.12 |
Hi @Data-drone , We will look into the langchain custom llms issue. Regarding setting |
Hi @Data-drone , which model are you using? Are you using an instruction-tuned model (that is not chat based)? |
Vicuna 1.5 13b |
hey @Data-drone , so we do have this snipped inside RagasLLMs that should handle this logic for you if isinstance(self.llm, BaseLLM):
ps = [p.format() for p in prompts]
result = self.llm.generate(ps, callbacks=callbacks)
else: # if BaseChatModel
ps = [p.format_messages() for p in prompts]
result = self.llm.generate(ps, callbacks=callbacks) if your custom model is a base class of either, it should do the conversation for you. but not sure why its not working here. Could you show us how you're calling the testsetgenerator and custom models code? |
@shahules786 @jjmachan In the same context, TestsetGenerator uses cross-encoder/stsb-TinyBERT-L-4/ from hugging face. Is there a way, i can avoid using that and just use gpt models from azure open ai alone and generate synthetic dataset? |
hey @msunkarahend thanks for bringing that up. what you can do is change it via the class class TestsetGenerator:
"""
Ragas Test Set Generator
Attributes
----------
generator_llm: LangchainLLM
LLM used for all the generator operations in the TestGeneration paradigm.
critique_llm: LangchainLLM
LLM used for all the filtering and scoring operations in TestGeneration
paradigm.
embeddings_model: Embeddings
Embeddings used for vectorizing nodes when required.
chat_qa: float
Determines the fraction of conversational questions the resulting test set.
chunk_size: int
The chunk size of nodes created from data.
test_distribution : dict
Distribution of different types of questions to be generated from given
set of documents. Defaults to {"easy":0.1, "reasoning":0.4, "conversation":0.5}
"""
def __init__(
self,
generator_llm: RagasLLM,
critic_llm: RagasLLM,
embeddings_model: Embeddings,
testset_distribution: t.Optional[t.Dict[str, float]] = None,
chat_qa: float = 0.0,
chunk_size: int = 1024,
seed: int = 42,
) -> None: so if you give a new different let me know if you want the finished snippet and I'll share that too 😄 |
but @shahules786 probably we should change |
@jjmachan If you can share the finished snippet for the TestsetGenerator, it would be great. thanks in advance. |
I notice that the if downloaded from source, the version of ragas on github is 0.0.23.dev44+g506ad60, while the latest version I down load from pip is 0.0.22, same as shown "latest realease" on github. And it seems like 0.0.22 will meet similar question about |
Could you guys try #670? |
…ngs (#670) ## **User description** The current version of `with_openai` contains a hardcoded instantiation of `langchain_openai.chat_models.ChatOpenAI`, which makes `TestsetGenerator` very limited and not compatible with completion models, Azure OpenAI models, and open-source models. This PR extends `TestsetGenerator` to any `BaseLanguageModel` and `Embeddings` from langchain for versatility, addressing #230, #342, #635, and #636. Lastly, I've removed all the occurrences of mutable default arguments (bad antipattern, read [here](https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments)). --------- Co-authored-by: Shahules786 <Shahules786@gmail.com> Co-authored-by: jjmachan <jamesjithin97@gmail.com>
Hi Team,
I am trying to get the
TestsetGenerator
to work properly with a Langchain custom LLM.It's
_call
method current expects a string prompt but it gets aChatPromptTemplate
from ragas. what is the best way to handle this?The text was updated successfully, but these errors were encountered: