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

First draft of concept pages #27088

Draft
wants to merge 7 commits into
base: concept_docs
Choose a base branch
from
Draft

Conversation

rlancemartin
Copy link
Collaborator

@rlancemartin rlancemartin commented Oct 3, 2024

No description provided.

Copy link

vercel bot commented Oct 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 30 unresolved
✅ 1 resolved
Oct 10, 2024 7:59pm

@@ -522,120 +522,6 @@ for modifying **multiple** key-value pairs at once:

For key-value store implementations, see [this section](/docs/integrations/stores/).

### Tools
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rlancemartin shall we keep the section headings everywhere to maintain a glossary on the main concepts page?

We can remove the beefy content, but maintain headings so no links break


Many AI applications interact directly with humans (e.g., chatbots). In these cases, it is approrpiate for models to respond in natural langague.

But what about cases where we want a model to interact *directly* with another system (e.g., a databases or an API)?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another vs. additional or some other paraphrasing to mean that the AI can interact with the human AND an external system


`ChatModel.bind_tools()` is a method for specifying which tools are available for a model to call.

If a model has been initialized as `llm` without tools, we can bind tools to it as a list:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to be more precise about chat model vs. llm terminology? We use them interchangeably in docs, but can be confusing?

We could also opt for favoring model?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is good point that i'm also wary of --
1/ maybe we defer to model by default
2/ conceptual guide on llm and chat model call out each specifically


For more details on usage, see our [how-to guides](docs/how_to/#tools)!

## Common patterns
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is a nice addition, not sure if i've seen this discussion before.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya -- we use this same framing in the course.

@@ -0,0 +1,133 @@
# Tool Calling
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a URL that we can link to that explains what a Tool is / brief example of definition/ brief example of how it can be used.

I think we need another page for tools specifically, or else retitle this page to `# Tools and have a tool calling section somewhere within it?

Some of the questions that the conceptual guide should address:

  1. What is a tool?
  2. Where is the tool getting executed? (maybe does a tool code need to be executed?)
  3. How does one define a tool? (We have 4-5 ways of doing it); e.g., @tool decorator, StructuredTool.from_function..... We don't need to do it in detail, but can link to the how-to guide, but just explain high level what the differences are.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's true. let me try to add as a section on this page.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also noted in Slack discussion. this is a good thing to flesh out --
https://langchain.slack.com/archives/C04GWPE38LV/p1728407895162059


## Motivation

While many AI applications, such as chatbots, typically respond in natural language, there are scenarios where we need models to output in a structured format.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this?

Suggested change
While many AI applications, such as chatbots, typically respond in natural language, there are scenarios where we need models to output in a structured format.
While many AI applications, such as chatbots, typically respond in natural language, there are scenarios where we need models to output a response matching a specific structured format.


## Indexing Strategies

Documents needed to be indexed, frequently using embedding models to [compress the semantic information in documents to fixed-size vectors](/docs/concepts/#embedding-models).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Has the term "Documents" been defined yet?
  • Should we use the more general term of "Content" or something along those lines so it's clear that conceptually some ideas carry to other modalities?


But chunk size and chunk number can be difficult to set and affect results if they do not provide full context for the LLM to answer a question.

Furthermore, LLMs are increasingly capable of processing millions of tokens.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latency is important for many applications.

Pulling in the content of the top 10 search hits can add significant latency.

In an extreme case, all 10 hits come from different documents.

In many domains, document length can run into the hundreds of pages (i've dozens if not hundreds of thousand page long documents in finance)

Even if the llm context window were unlimited (and could incorporate information from the context perfectly), implementation details still introduce a tradeoff in terms of latency.

Is a user willing to wait for an extra 5-60 seconds to get an answer from a chat system? This ends up being very use case dependent.


In some cases, irrelevant or redundant content can dilute the semantic usefulness of the embedding.

[ColBERT](https://docs.google.com/presentation/d/1IRhAdGjIevrrotdplHNcc4aXgIYyKamUKTWtB3m3aMU/edit?usp=sharing) is an interesting approach to address this with a higher granularity embeddings: (1) produce a contextually influenced embedding for each token in the document and query, (2) score similarity between each query token and all document tokens, (3) take the max, (4) do this for all query tokens, and (5) take the sum of the max scores (in step 3) for all query tokens to get a query-document similarity score; this token-wise scoring can yield strong results.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is describing how to implement the algorithm, but it's not explaining what the algorithm does at a conceptual level. I think most readers will gloss over this description as a result since it's not conceptual.

It would be helpful to have a sentence in the spirit of: a variation that generates multiple embeddings for the query, and retrieves closest documents to any of these embeddings


Language models (LLMs) are trained on vast but fixed datasets, which limits their ability to access up-to-date or domain-specific information.

To enhance their performance on specific tasks, we can augment their knowledge using retrieval systems.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"retrieval systems" => external information (see other related comment)

In LangChain, any function can be bound as a tool.

```python
def multiply(a: int, b: int) -> int:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we usually need a @tool decorator (since some code probably assumes that the tool is a runnable) at invocation time

Suggested change
def multiply(a: int, b: int) -> int:
def multiply(a: int, b: int) -> int:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage
Development

Successfully merging this pull request may close these issues.

2 participants