docs:misc fixes (#9671)

Improve internal consistency in LangChain documentation
- Change occurrences of eg and eg. to e.g.
- Fix headers containing unnecessary capital letters.
- Change instances of "few shot" to "few-shot".
- Add periods to end of sentences where missing.
- Minor spelling and grammar fixes.
This commit is contained in:
seamusp
2023-08-23 22:36:54 -07:00
committed by GitHub
parent 6283f3b63c
commit 25f2c82ae8
25 changed files with 85 additions and 106 deletions

View File

@@ -1,13 +1,13 @@
### Use Case
In this tutorial, we'll configure few shot examples for self-ask with search.
In this tutorial, we'll configure few-shot examples for self-ask with search.
## Using an example set
### Create the example set
To get started, create a list of few shot examples. Each example should be a dictionary with the keys being the input variables and the values being the values for those input variables.
To get started, create a list of few-shot examples. Each example should be a dictionary with the keys being the input variables and the values being the values for those input variables.
```python
from langchain.prompts.few_shot import FewShotPromptTemplate
@@ -69,9 +69,9 @@ So the final answer is: No
]
```
### Create a formatter for the few shot examples
### Create a formatter for the few-shot examples
Configure a formatter that will format the few shot examples into a string. This formatter should be a `PromptTemplate` object.
Configure a formatter that will format the few-shot examples into a string. This formatter should be a `PromptTemplate` object.
```python
@@ -98,7 +98,7 @@ print(example_prompt.format(**examples[0]))
### Feed examples and formatter to `FewShotPromptTemplate`
Finally, create a `FewShotPromptTemplate` object. This object takes in the few shot examples and the formatter for the few shot examples.
Finally, create a `FewShotPromptTemplate` object. This object takes in the few-shot examples and the formatter for the few-shot examples.
```python
@@ -171,7 +171,7 @@ print(prompt.format(input="Who was the father of Mary Ball Washington?"))
We will reuse the example set and the formatter from the previous section. However, instead of feeding the examples directly into the `FewShotPromptTemplate` object, we will feed them into an `ExampleSelector` object.
In this tutorial, we will use the `SemanticSimilarityExampleSelector` class. This class selects few shot examples based on their similarity to the input. It uses an embedding model to compute the similarity between the input and the few shot examples, as well as a vector store to perform the nearest neighbor search.
In this tutorial, we will use the `SemanticSimilarityExampleSelector` class. This class selects few-shot examples based on their similarity to the input. It uses an embedding model to compute the similarity between the input and the few-shot examples, as well as a vector store to perform the nearest neighbor search.
```python
@@ -224,7 +224,7 @@ for example in selected_examples:
### Feed example selector into `FewShotPromptTemplate`
Finally, create a `FewShotPromptTemplate` object. This object takes in the example selector and the formatter for the few shot examples.
Finally, create a `FewShotPromptTemplate` object. This object takes in the example selector and the formatter for the few-shot examples.
```python

View File

@@ -1,4 +1,4 @@
## Partial With Strings
## Partial with strings
One common use case for wanting to partial a prompt template is if you get some of the variables before others. For example, suppose you have a prompt template that requires two variables, `foo` and `baz`. If you get the `foo` value early on in the chain, but the `baz` value later, it can be annoying to wait until you have both variables in the same place to pass them to the prompt template. Instead, you can partial the prompt template with the `foo` value, and then pass the partialed prompt template along and just use that. Below is an example of doing this:
@@ -40,7 +40,7 @@ print(prompt.format(bar="baz"))
</CodeOutputBlock>
## Partial With Functions
## Partial with functions
The other common use is to partial with a function. The use case for this is when you have a variable you know that you always want to fetch in a common way. A prime example of this is with date or time. Imagine you have a prompt which you always want to have the current date. You can't hard code it in the prompt, and passing it along with the other input variables is a bit annoying. In this case, it's very handy to be able to partial the prompt with a function that always returns the current date.