-
Notifications
You must be signed in to change notification settings - Fork 460
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
[R-228] Testset generation. TypeError: unsupported operand type(s) for -: 'str' and 'int' #900
Comments
hey @GaalDorn1k I'm actually not sure about this - could you give me some time to get back to this. I've added this to our linear workflow but feel free to make a PR too if you want - we can work of from there 🙂 |
I had the same issue and indeed the fix is the following: selected_nodes = [
current_nodes.nodes[i - 1]
for i in relevant_context_indices
- if i - 1 < len(current_nodes.nodes)
+ if int(i) - 1 < len(current_nodes.nodes)
]
relevant_context = (
CurrentNodes(root_node=selected_nodes[0], nodes=selected_nodes) @GaalDorn1k it is however strange the your error trace already contains the fix... I am not sure how that can happen, but I assume that the error was triggered because the Btw, the error is not 100% deterministic. I think it has to do with the json parsing returning integers sometimes as integers and sometimes as strings. |
@HerrIvan In my case type casting is also needed on line 211. In addition, the error also occurs when running not in notebook. |
@jjmachan After thinking a little, I began to suspect that the cause of thre error was using FastChat to run the model. It seems that the fastchat server is no different in appearance from the openai server. But this may not be the case, since the error is not observed when using the vllm server. Also, I am running an openchat model named "gpt-3.5-turbo" for langchain integration. This may be the reason for the error. Now, I'm not sure that is a bug, since i haven't found information anywhere about whether Ragas should work with FatChat. In any case, I'm going to spend a little time to find the final causes of the error, since I need to work with FastChat. |
Oh yes, you are absolutely right about the additional type casting needed.
Hey @GaalDorn1k. I also encountered the issue running the testset generation from the terminal. I think the issue is (or was) that the json generation can happen in two steps: a direct casting, and if that one fails, an additional request to the LLM. One of these actions was sometimes returning integers as strings. In the meantime this repo has had some updates in the output parsing, so maybe the issue is not there anymore. But I think the fix with the type casting cannot hurt. I made a PR since I would actually I need this fix to be able to run my workflows without using a forked repo. |
Hi @HerrIvan. It will be great if your PR closes the issue. Until then I'm also forced to use a forked repo |
[ *] I have checked the documentation and related resources and couldn't resolve my bug.
Describe the bug
TestsetGenerator.generate_with_langchain_docs()
returns an empty TestDataset object withTypeError: unsupported operand type(s) for -: 'str' and 'int'
Ragas version: 0.1.8
Python version: 3.10.0
Code to Reproduce
Error trace
Expected behavior
TestsetGenerator.generate_with_langchain_docs() returns a non-empty TestDataset object
Additional context
The error can actually be corrected by editing the file
editing ragas\src\ragas\testset\evolutions.py
:If I were confident in the reliability of this fix, I would create a PR
R-228
The text was updated successfully, but these errors were encountered: