Git Product home page Git Product logo

Comments (4)

pchalasani avatar pchalasani commented on June 12, 2024

can you run on a larger prompt and see whether the difference is a constant or it grows with the prompt size. If a constant, it could be that during handling of stream response, we are missing something at the beginning or end. Also if the diff is a constant , it's not a serious issue. If the true and computed costs are off by a slight constant amount, we should be fine.

from langroid.

Mohannadcse avatar Mohannadcse commented on June 12, 2024

Some trials here are based on the app examples/docqa/chat_multi.py
@pchalasani I don't see there is a constant difference, let me know if you are interested in other cases.

Stream: True

Enter input (type 'done' or hit return to finish): https://www.darpa.mil/
Enter input (type 'done' or hit return to finish): 
I have processed the following 1 URLs 
        and 0 paths into 1 parts:
https://www.darpa.mil/

1. The concept of tags.
2. The connection between tags and similarly tagged content.
3. The role of tags in categorizing images.
Stream: True
prompt_tokens: 35
completion_tokens: 29

>>> Starting Agent WriterAgent (1) 

                LLM Initial Msg History:
                Role.SYSTEM : 
        You have to collect some information from some documents, on these topics:
        1. The concept of tags.
2. The connection between tags and similarly tagged content.
3. The role of tags in categorizing images.
        However you do not have access to those documents. 
        You can ask me questions about them, ONE AT A TIME, I will answer each 
        question. 
        Once you have collected 5 key pieces of information, say "DONE" and summarize 
        them in bullet points.  
        
                
What is the concept of tags in the context of these documents?
Stream: True
prompt_tokens: 109
completion_tokens: 13

[Entity.LLM]Entity.LLM[] What is the concept of tags in the context of these documents?
Human (respond or q, x to exit current level, or hit enter to continue)
: 
...|>>> Starting Agent DocAgent (2) 
SUMMARIZE_PROMPT=  Use the provided extracts (with sources)  to answer the question. 
        If there's not enough information, respond with DO-NOT-KNOW. Use only the 
        information in these extracts, even if your answer is factually incorrect, 
        and even if the answer contradicts other parts of the document. The only 
        important thing is that your answer is consistent with and supported by the 
        extracts. Compose your complete answer and cite all supporting sources on a 
        separate separate line as follows. For each SOURCE, (a) show the source name,
        and (b) the exact EXTRACT from the source that supports your answer.
        DO NOT SHOW THE FULL EXTRACT; only show the FIRST 3 words and LAST 3 words.  
        For example:
        SOURCE:  https://en.wikipedia.org/wiki/Tree
        EXTRACTS: "The tree species ... oak, maple, and birch."
        
        SOURCE: https://en.wikipedia.org/wiki/Oak
        EXTRACTS: "The oak trees ... longevity and strength."
        
        
                Extract: Tags
|
Similarly Tagged Content
Images
                Source: https://www.darpa.mil/
                
        
        Question:What is the concept of tags in the context of these documents?
        Answer:

                LLM Initial Msg History:
                Role.SYSTEM : You will receive various questions about some documents, and
        your job is to answer them concisely in at most 2 sentences, citing sources.
        
Role.USER : 
Your task is to answer questions about various documents.
You will be given various passages from these documents, and asked to answer questions 
about them, or summarize them into coherent answers.

                
...|DO-NOT-KNOW
Stream: True
prompt_tokens: 344
completion_tokens: 5

SUMMARIZE_RESPONSE=  DO-NOT-KNOW
[Entity.LLM]Entity.LLM[] DO-NOT-KNOW
...|<<< Finished Agent DocAgent (4) 
[Entity.USER]Entity.USER[] DO-NOT-KNOW
In general, how do tags work in categorizing content?
Stream: True
prompt_tokens: 127
completion_tokens: 12

Stream: False:

Enter input (type 'done' or hit return to finish): https://www.darpa.mil/
Enter input (type 'done' or hit return to finish): 
I have processed the following 1 URLs 
        and 0 paths into 1 parts:
https://www.darpa.mil/

1. The concept of tags.
2. The exploration of similarly tagged content.
3. The use of images in content.
Stream: False
prompt_tokens: 52
completion_tokens: 25

>>> Starting Agent WriterAgent (1) 

                LLM Initial Msg History:
                Role.SYSTEM : 
        You have to collect some information from some documents, on these topics:
        1. The concept of tags.
2. The exploration of similarly tagged content.
3. The use of images in content.
        However you do not have access to those documents. 
        You can ask me questions about them, ONE AT A TIME, I will answer each 
        question. 
        Once you have collected 5 key pieces of information, say "DONE" and summarize 
        them in bullet points.  
        
                
What is the concept of tags in the context of these documents?
Stream: False
prompt_tokens: 112
completion_tokens: 13

[Entity.LLM]Entity.LLM[] What is the concept of tags in the context of these documents?
Human (respond or q, x to exit current level, or hit enter to continue)
: 
...|>>> Starting Agent DocAgent (2) 
SUMMARIZE_PROMPT=  Use the provided extracts (with sources)  to answer the question. 
        If there's not enough information, respond with DO-NOT-KNOW. Use only the 
        information in these extracts, even if your answer is factually incorrect, 
        and even if the answer contradicts other parts of the document. The only 
        important thing is that your answer is consistent with and supported by the 
        extracts. Compose your complete answer and cite all supporting sources on a 
        separate separate line as follows. For each SOURCE, (a) show the source name,
        and (b) the exact EXTRACT from the source that supports your answer.
        DO NOT SHOW THE FULL EXTRACT; only show the FIRST 3 words and LAST 3 words.  
        For example:
        SOURCE:  https://en.wikipedia.org/wiki/Tree
        EXTRACTS: "The tree species ... oak, maple, and birch."
        
        SOURCE: https://en.wikipedia.org/wiki/Oak
        EXTRACTS: "The oak trees ... longevity and strength."
        
        
                Extract: Tags
|
Similarly Tagged Content
Images
                Source: https://www.darpa.mil/
                
        
        Question:What is the concept of tags in the context of these documents?
        Answer:

                LLM Initial Msg History:
                Role.SYSTEM : You will receive various questions about some documents, and
        your job is to answer them concisely in at most 2 sentences, citing sources.
        
Role.USER : 
Your task is to answer questions about various documents.
You will be given various passages from these documents, and asked to answer questions 
about them, or summarize them into coherent answers.

                
DO-NOT-KNOW
⠴ LLM Generating final answer...Stream: False
prompt_tokens: 359
completion_tokens: 5

SUMMARIZE_RESPONSE=  DO-NOT-KNOW
[Entity.LLM]Entity.LLM[] DO-NOT-KNOW
...|<<< Finished Agent DocAgent (4) 
[Entity.USER]Entity.USER[] DO-NOT-KNOW
⠼ LLM responding to messages...

from langroid.

pchalasani avatar pchalasani commented on June 12, 2024

It could be that the OpenAI API inserts some extra instructions/roles in the system prompt, so when it reports prompt tokens (in non-stream mode), it includes those, which is probably why their number is higher than ours. The diffs are not that significant, we can punt on this

from langroid.

Mohannadcse avatar Mohannadcse commented on June 12, 2024

I think we can close this now, but will keep an eye on it

from langroid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.