feat: Add source reference metadata to chat response#241
Conversation
Codecov Report
@@ Coverage Diff @@
## main #241 +/- ##
==========================================
- Coverage 77.30% 76.44% -0.87%
==========================================
Files 111 99 -12
Lines 6170 5518 -652
Branches 576 576
==========================================
- Hits 4770 4218 -552
+ Misses 1384 1284 -100
Partials 16 16 see 12 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
sehyod
left a comment
There was a problem hiding this comment.
Nice! This greatly improves the chat experience!
|
This looks great! The ability to cite multiple sources is very useful as well. I also found a tutorial demonstrating similar functionality - https://github.com/gkamradt/langchain-tutorials/blob/cc89c780e6484bdc3b15a967c1be2a5bfa4934dc/data_generation/Custom%20Files%20Question%20%26%20Answer.ipynb#L9 |
|
I'm sorry about the back-and-forth regarding this feature, but I'm a bit concerned about this update, which feels like regression to me. The reply we were getting before for the question about hidden feedback loops was the following: The new reply is: Although we now get citations with a proper schema, I think the reply contains far less details. And another issue is that we don't know which part of the answer corresponds to which citation. |
|
I'm ok with reverting to the other solution and regex/parse the reference for now and work on the improved solution in a different PR. |
|
Yes, requiring JSON output means less available token space in the response, and it also means eating up a lot more of the input context space due to requiring more directions in the prompt. It took a lot of trial and error to have a prompt that resulted in JSON output and also left enough of the input context space for the relevant text chunks. I don't love the idea of reworking this again and trying to regex out a somewhat non-deterministic result from the LLM, but can give it a shot if we think it's worth the time. I think the best approach for now would be to move forward with how this PR previously was (with inline citations) and then I can add a follow-up PR to regex out the citations if we think it's valuable. |
|
@gjreda we see your point. Ok. Push a revert to this branch and let me know when it's ready for a new review. |
This reverts commit cbad0ff.
2f97c4e to
f1d8d4a
Compare
|
@cguedes Sound good, should be good to go now and I'll work on a separate regex PR. |
fixes #143
Some examples below.
Note that in the first example, the LLM appropriately cities multiple sources. I was surprised that it nicely combined them without an example or being told how to do so.