Compare commits

...

95 Commits

Author SHA1 Message Date
Eugene Yurtsev eb2d9e2b63 Update notebooks, model registry and make release (#131)
see release notes
2023-12-14 13:25:13 -05:00
Eugene Yurtsev 09d214522f Add version (#130)
Add __version__ and lint
2023-12-14 12:20:27 -05:00
Eugene Yurtsev 8798735ea4 Adds custom agents to the langchain benchmarking repo (#120)
* This PR adds code for running custom agents to the langchain
benchmarking repo.
* The agent code is good enough for experimentation / prototyping, but I
don't think it's good enough for the langchain repo:
-- The abstractions aren't fully implemented and aren't ready for
production use -- but OK for research
-- For production use, one may want to remove all the intermediate
abstractions to keep the agent as simple as possible

I was thinking initially of including this in a different repo, but I
think it's over-complicating things, probably OK to include some
reference implementations inside of langchain benchmarks.
2023-12-14 12:05:59 -05:00
William FH 7ed859c068 Add gemini mm examples (#125) 2023-12-13 17:07:22 -08:00
Eugene Yurtsev 417e6faccf Update fireworks models (#128)
Update fireworks models
2023-12-13 15:31:15 -05:00
Eugene Yurtsev aeae13ba63 remove with_rate_limit from public api (#127)
Because it's not a runnable binding it breaks things like .bind etc,
let's use
it internally but not expose to users
2023-12-13 15:30:53 -05:00
Eugene Yurtsev 825d8ec9bb Add __contains__ to model registry (#126)
Code is already using `in` checks but they will fail since __contains__
isn't defined correctly
2023-12-13 15:24:34 -05:00
Eugene Yurtsev 44a5c3530a Bump ruff fix up first party identity for import sorting (#124)
Minor change to bump ruff and fix up config
2023-12-13 13:51:17 -05:00
Eugene Yurtsev 14de11a420 Add rate limiter (#121)
This PR adds a simple rate limiter based on a token bucket.

I would love to extend RunnableBinding with this, we just need to make
sure there's no funny async vs. threading business.

This should be sufficient for benchmarking for now.
2023-12-13 13:12:21 -05:00
Lance Martin b15620ee9c Minor clean, add Mixtral (#123) 2023-12-13 07:59:12 -08:00
Lance Martin 13e7f2df0a Add semi-structured eval (#83)
1/ Create datasets for semi-structured eval
2/ Benchmark several methods
2023-12-12 14:04:31 -08:00
Eugene Yurtsev 888fce5060 Release 0.0.8 (#122)
See release notes
2023-12-12 11:39:05 -05:00
Eugene Yurtsev 148a3e4f89 Benchmark all tool usage notebook (#118)
* This PR adds a notebook that benchmarks all tool usage tasks.

To make it easier to work with task registry:

* Add `type` property to tasks.
* Add __iter__ and __len__ and support for slices in __item__ for task
  registry.
2023-12-11 22:49:46 -05:00
Eugene Yurtsev 0e10f3227f Add gpt-4 models (#117)
Register gpt-4 models
2023-12-11 22:11:40 -05:00
William FH b0667043ea Move mixtral models (#115) 2023-12-11 16:04:13 -08:00
William FH bd5eac5abd Add mixtral tool use examples (#114) 2023-12-11 14:40:02 -08:00
William FH dbb85200ac Update evaluator (#113) 2023-12-11 09:52:13 -08:00
Eugene Yurtsev c1023a14b8 Tool Tasks: Add eval params to task definition (#112)
This will make it easier to treat all tasks uniformly.
2023-12-11 09:52:02 -08:00
Eugene Yurtsev 8899acc989 Update model registry (#111)
* Add more models
* Fix path to language models
* Notebook instantiates some of the models to test that it works
2023-12-08 22:52:02 -05:00
Eugene Yurtsev c0e7f51626 Add Model Registry (#110)
Add a model registry to make it easier to iterate through models for
bench-marking purposes
2023-12-08 12:09:10 -05:00
Eugene Yurtsev 9f827eaca5 Update README.md (#108) 2023-12-07 13:38:25 -05:00
Eugene Yurtsev d9fc08b05c Update README.md (#107) 2023-12-07 13:34:55 -05:00
Lance Martin 8a5ba6d575 Minor cleanup to multi-modal embeddings docs (#105) 2023-12-05 13:40:42 -08:00
William FH 8204930f2b 0.0.7 (#104)
Adds the multimodal benchmark.
2023-12-05 13:14:44 -08:00
Lance Martin 013fe6a153 Multi modal RAG benchmark (#101)
* Example notebooks for eval of multi-modal RAG w/ mm-embd and
mv-retriever vs baseline top-k RAG

---------

Co-authored-by: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com>
2023-12-05 12:04:01 -08:00
William FH 01ffffd04c Update Chat Extraction Notebook (#102) 2023-12-03 18:28:51 -08:00
William FH 4ddbbc0ff8 Add Archived (#53)
Moves the other tasks to the archive
2023-12-01 10:56:44 -08:00
William FH 5ffdbb5c4c Add chat categorization dataset (#98)
This task is meant to test a couple things:
1. Classification -> both on common things where it is expected to
perform well (e.g., sentiment, toxicity -> which currently is always 0)
2. Structured json output -> the schema is nested, which confused some
of the smaller 7b models i tested out but works fine for llama 32b code
instruct (and OAI/anthropic)


Includes a couple common things like enums.
2023-12-01 10:17:50 -08:00
Eugene Yurtsev 30530883d4 Release 0.0.5 (#100)
Release
2023-12-01 10:40:03 -05:00
Eugene Yurtsev 9284a7c4f4 Make it easier to test non standard agents (#99)
Make it easier to test an agent which isn't built from an agent executor
2023-12-01 10:33:51 -05:00
Eugene Yurtsev 646aaab6c1 Clean up notebooks, and trim cells (#97)
* Cleans up accidental cell commit in relational data
* Trim dataframes (they don't render well in sphinx docs)
* Full dataframes have been included with remove-cell tag which will
show them
  only in the source notebook
2023-11-29 17:58:07 -05:00
Eugene Yurtsev d61eaf683d Version 0.0.4 (#96)
Version 0.0.4
2023-11-29 17:31:40 -05:00
Eugene Yurtsev 4a528670f6 Added benchmarks to typerwriter 1, multiverse, relational data, update evaluators (#92)
* Added benchmarks to typerwriter 1, multiverse, relational data
* Updated the evaluator to be more configurable; it'll grade the
multiverse math correctly now + allow skipping grading `output` for
typewriter tasks
* Fixed examples in a dataset (updated them already in the public
dataset)
2023-11-29 17:29:23 -05:00
William FH d6addec366 Add more comparisons (#95) 2023-11-28 15:46:32 -08:00
William FH 314627635b 0.0.3 (#94) 2023-11-28 15:31:14 -08:00
William FH 6c3dcb6c11 Limit Retries in OpenAI (#93) 2023-11-28 15:24:49 -08:00
William FH f912841118 Extraction Update (#91) 2023-11-28 11:20:35 -08:00
Eugene Yurtsev 55ea29817c Fix dataset example for multiverse math (#90)
Fix dataset example for multiverse math
2023-11-28 14:01:15 -05:00
Eugene Yurtsev 9e911d1d3e Tool Usage updates (#89)
* Update documentation to show how to create an agent factory in intro
* Update relational data documentation to add markdown tables
* in relational data evaluate with a few different open ai models
* Relational data notebook seems to hang for me during eval right now --
we need to trace what's going on
* Updated poetry lock file to be on most recent versions of langchain
and langmsith and also avoid yanked versions of two of jupyter lab deps
2023-11-28 13:27:29 -05:00
Eugene Yurtsev cc30612d12 Make output optional too (#82)
Make it optional to evaluate `output` for correctness -- usefulf or
agents that do not have a useful output

---------

Co-authored-by: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com>
2023-11-22 14:41:13 -08:00
William FH c6b6181302 Wfh/descriptive names (#79) 2023-11-22 11:53:57 -08:00
William FH 8f4321c06b Improve Prefix for key hint (#72) 2023-11-22 11:51:40 -08:00
Eugene Yurtsev 5b153a64ce Version 0.0.2 (#81) 2023-11-22 14:45:03 -05:00
Eugene Yurtsev bd2123f4a8 Minor documentation fixes (#80)
Minor fixes
2023-11-22 14:42:41 -05:00
Eugene Yurtsev a585ad7e93 Update standard agent evaluator + update notebooks (#78)
This updates the standard agent evaluator to use order_matters
2023-11-22 14:33:26 -05:00
Eugene Yurtsev 30aa706d9c Add colab links (#77)
Add colab links

---------

Co-authored-by: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com>
2023-11-22 11:04:10 -08:00
Eugene Yurtsev 99a54c49e5 Tool usage docs (#76)
Update introduction doc
2023-11-22 11:38:28 -05:00
Eugene Yurtsev d7ae76cf66 Rename intros (#75)
Minor change to rename notebooks to say Introduction
2023-11-22 10:16:26 -05:00
William FH d8d63cbc4c Device 0 default (#73)
Faster for notebooks, etc.
2023-11-22 05:17:12 -08:00
William FH 22b83afb72 update link (#71) 2023-11-22 04:48:56 -08:00
William FH e6fd329869 Add links, update (#70)
- dataset page had a now broken link
- add collab links
- fix pip install command
2023-11-21 22:38:43 -08:00
William FH ca14a4ef3b Wfh/rerun notebooks (#69)
Add links to the notebooks
2023-11-21 19:26:19 -08:00
Eugene Yurtsev 97b2c28d09 Relax langchain constraints (#68)
Relaxed constraints
2023-11-21 19:25:50 -08:00
Eugene Yurtsev 1130f60d40 Add badges to README (#67)
Add badges
2023-11-21 22:05:42 -05:00
Eugene Yurtsev b7dcec1773 Add MIT license (#66)
Add MIT license
2023-11-21 22:04:25 -05:00
William FH 7fca17e14d Update repo structure in readme (#65)
Add note about repo structure
2023-11-21 18:46:37 -08:00
William FH bb7a461a57 Wfh/update name (#64)
- Update the semistructured name to be "reports"
- Fixup some caching logic for semi-structured
2023-11-21 18:37:27 -08:00
William FH 5edf648440 Update extraction dataset (#63) 2023-11-21 17:41:24 -08:00
William FH bb484906d2 Add docs link (#62) 2023-11-21 16:22:20 -08:00
William FH a1e774ea7a Agent Intros (#61) 2023-11-21 16:20:22 -08:00
William FH ed357c9924 Add extraction intro (#60)
Add intro doc for tools, reshuffles some things.
2023-11-21 16:07:47 -08:00
William FH c1b0cf9851 Add retrieval intro; Add links (#59)
- Adds links so you can more easily click and navigate
- Adds intro describing rag task and schema
2023-11-21 15:25:09 -08:00
William FH 32ae959be5 Change schema for semi-structured (#58) 2023-11-21 14:34:06 -08:00
Eugene Yurtsev a5caa1c13a Another toc update (#57)
Update toc
2023-11-21 17:22:22 -05:00
William FH eb5e761a33 Update notebooks (#47) 2023-11-21 14:17:19 -08:00
William FH ae5064fe94 Add Quick Start (#52)
Gonna have to rewrite a lot when I refactor the other docs
2023-11-21 14:17:07 -08:00
Eugene Yurtsev 9b6c0c6d39 Update notebooks toc (#56)
Update toc
2023-11-21 17:15:47 -05:00
Eugene Yurtsev dd9cf5e69a Move RAG unit tests (#55)
Move to unit tests dir
2023-11-21 17:01:53 -05:00
Eugene Yurtsev a9bf422a15 Check public datasets exist (#54)
Check public datasets exist
2023-11-21 16:58:44 -05:00
Eugene Yurtsev 37be748aa7 More tool usage updates (#51)
More tool usage updates
2023-11-21 16:33:53 -05:00
William FH ca845ca821 Make the example explicit (#49)
For the unstructured config
2023-11-21 13:29:12 -08:00
William FH dfc6c57347 Switch to api (#50)
Supposedly the cloud armor rule will be removed as well but keeping the
placeholder for now
2023-11-21 13:28:51 -08:00
Eugene Yurtsev b59722eda4 Add multiverse math notebook, update dataset id (#48)
Add notebook and update id
2023-11-21 15:02:36 -05:00
Eugene Yurtsev 7253b433a3 Add datasets for tool usage tasks (#46)
Add datasets
2023-11-21 13:19:39 -05:00
William FH fd0203c7b8 Add filter option (#45)
Default list is long now. This would let you do something like

```
registry.filter(Type="RetrievalTask")
```
2023-11-21 09:48:53 -08:00
William FH b3aee9d5a2 Add RAG tasks (#43)
Still need to tidy up notebooks but rest is OK for now

---------

Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
2023-11-21 08:46:09 -08:00
Eugene Yurtsev d99756a91f Bump dependencies for doc building (#44)
Bump deps
2023-11-21 11:38:57 -05:00
Eugene Yurtsev 029866786d Update lock file (#42)
Update lock file
2023-11-21 10:52:32 -05:00
Eugene Yurtsev 12e03473b0 Update notebook for extraction (#41)
Update extraciton notebook
2023-11-21 10:39:38 -05:00
Eugene Yurtsev e07ac06b30 Add more extraction code (#37)
Add more extraction code
2023-11-21 09:38:14 -05:00
Eugene Yurtsev c3504851da Update langchain, relax requirements for deps (#40)
* Relax requirement for deps
* Bump langchain
* Bump langsmith
2023-11-21 09:37:52 -05:00
Eugene Yurtsev abde07e167 Update doc build (#39)
Update doc build to use README.md and add toc with all notebooks added by default.
2023-11-20 21:51:12 -05:00
Eugene Yurtsev 3b0e6e1d61 Fix typo in workflow to publish docs (#36)
Publish docs
2023-11-20 16:23:04 -05:00
Eugene Yurtsev e6ddfbf892 Create doc publish workflow (#35)
Add workflow for publishing docs
2023-11-20 16:19:04 -05:00
Eugene Yurtsev 50624008bb Expand CI to also build sphinx docs (#34)
Adding a step to the ci tester to try to build sphinx docs
2023-11-20 16:13:37 -05:00
Eugene Yurtsev 3d731bf937 Restore tasks namespace, create agent factory (#33)
Create an agent factory for evaluating tool usage tasks
2023-11-20 15:50:53 -05:00
Eugene Yurtsev 0989f96d2d Remove ID that doens't exist (#31)
x
2023-11-20 14:30:36 -05:00
Eugene Yurtsev 0abb4f00b9 Refactor to remove ID from task, move task definitions out of registry.py (#30)
Refactor to remove ID from task, move task definitions out of registry.py (#30)
2023-11-20 14:28:06 -05:00
Eugene Yurtsev f79d7972bf Add extraction task (#29)
Add extraction task
2023-11-20 14:03:49 -05:00
Eugene Yurtsev 5f2ce54b40 Add additional tasks, re-org repo a bit (#26)
* Push registry to top level
* Rename environments to tasks
* Tool usage tasks can create an environment; an environment can be associated with a state that can be read
* Add additional tasks
2023-11-20 11:30:26 -05:00
Eugene Yurtsev 65aeb987b0 Add registry object, add eval notebook (#25)
Add registry object
Add eval notebook
2023-11-17 17:27:01 -05:00
Eugene Yurtsev d9582803f8 Update description (#24)
Important
2023-11-16 15:10:00 -08:00
Eugene Yurtsev f80989adb1 Add datasets notebook (#23)
Add datasets notebook
2023-11-16 16:47:53 -05:00
Eugene Yurtsev d58e43eed3 x (#22) 2023-11-16 16:38:56 -05:00
Eugene Yurtsev ca0eb25694 Scaffold for sphinx docs (#21)
Add docs scaffolding
2023-11-16 16:17:45 -05:00
205 changed files with 23632 additions and 587 deletions
+67 -1
View File
@@ -66,7 +66,7 @@ jobs:
shell: bash
run: |
echo "Running tests, installing dependencies with poetry..."
poetry install --with test,lint,typing
poetry install --with test,lint,typing,docs
- name: Run tests
run: make test
@@ -82,3 +82,69 @@ jobs:
# grep will exit non-zero if the target message isn't found,
# and `set -e` above will cause the step to fail.
echo "$STATUS" | grep 'nothing to commit, working tree clean'
test_docs:
timeout-minutes: 5
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKDIR }}
strategy:
matrix:
python-version:
- "3.11"
name: Documentation Build for Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
with:
python-version: ${{ matrix.python-version }}
poetry-version: ${{ env.POETRY_VERSION }}
working-directory: .
cache-key: benchmarks-all
- name: Install dependencies
shell: bash
run: |
echo "Running tests, installing dependencies with poetry..."
poetry install --with test,lint,typing,docs
- name: Test Sphinx Docs
shell: bash
run: |
echo "Attempting to build docs..."
make build_docs
test_datasets:
timeout-minutes: 5
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKDIR }}
strategy:
matrix:
python-version:
- "3.11"
name: Validate Public Datasets
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
with:
python-version: ${{ matrix.python-version }}
poetry-version: ${{ env.POETRY_VERSION }}
working-directory: .
cache-key: benchmarks-all
- name: Install dependencies
shell: bash
run: |
echo "Running tests, installing dependencies with poetry..."
poetry install --with test,lint,typing,docs
- name: Request datasets
shell: bash
run: |
echo "Attempting to build docs..."
poetry run python -m scripts.check_datasets
+44
View File
@@ -0,0 +1,44 @@
name: Publish Docs
on: [workflow_dispatch]
permissions:
contents: write
env:
POETRY_VERSION: "1.6.1"
jobs:
docs:
strategy:
matrix:
python-version:
- "3.11"
runs-on: ubuntu-latest
name: Documentation Publish
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_setup"
with:
python-version: ${{ matrix.python-version }}
poetry-version: ${{ env.POETRY_VERSION }}
working-directory: .
cache-key: benchmarks-all
- name: Install dependencies
shell: bash
run: |
echo "Running tests, installing dependencies with poetry..."
poetry install --with test,lint,typing,docs
- name: Sphinx build
shell: bash
run: |
make build_docs
- name: Publish Docs
uses: peaceiris/actions-gh-pages@v3
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build
force_orphan: true
+1 -1
View File
@@ -159,4 +159,4 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.DS_Store
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Langchain AI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+10
View File
@@ -16,6 +16,16 @@ test:
test_watch:
poetry run ptw . -- $(TEST_FILE)
build_docs:
# Copy README.md to docs/index.md
cp README.md ./docs/source/index.md
# Append to the table of contents the contents of the file
cat ./docs/source/toc.segment >> ./docs/source/index.md
poetry run sphinx-build "./docs/source" "./docs/build"
clean_docs:
rm -rf ./docs/build
######################
# LINTING AND FORMATTING
######################
+51 -9
View File
@@ -1,8 +1,19 @@
# 🦜💪 LangChain Benchmarks
# 🦜💯 LangChain Benchmarks
This repository shows how we benchmark some of our more popular chains and agents.
The benchmarks are organized by end-to-end use cases.
They utilize [LangSmith](https://smith.langchain.com/) heavily.
[![Release Notes](https://img.shields.io/github/release/langchain-ai/langchain-benchmarks)](https://github.com/langchain-ai/langchain-benchmarks/releases)
[![CI](https://github.com/langchain-ai/langchain-benchmarks/actions/workflows/ci.yml/badge.svg)](https://github.com/langchain-ai/langchain-benchmarks/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchainai.svg?style=social&label=Follow%20%40LangChainAI)](https://twitter.com/langchainai)
[![](https://dcbadge.vercel.app/api/server/6adMQxSpJS?compact=true&style=flat)](https://discord.gg/6adMQxSpJS)
[![Open Issues](https://img.shields.io/github/issues-raw/langchain-ai/langchain-benchmarks)](https://github.com/langchain-ai/langchain-benchmarks/issues)
[📖 Documentation](https://langchain-ai.github.io/langchain-benchmarks/index.html)
A package to help benchmark various LLM related tasks.
The benchmarks are organized by end-to-end use cases, and
utilize [LangSmith](https://smith.langchain.com/) heavily.
We have several goals in open sourcing this:
@@ -11,8 +22,39 @@ We have several goals in open sourcing this:
- Showing how we evaluate each task
- Encouraging others to benchmark their solutions on these tasks (we are always looking for better ways of doing things!)
We currently include the following tasks:
- [CSV Question Answering](csv-qa)
- [Extraction](extraction)
- [Q&A over the LangChain docs](langchain-docs-benchmarking)
- [Meta-evaluation of 'correctness' evaluators](meta-evals)
## Installation
To install the packages, run the following command:
```bash
pip install -U langchain-benchmarks
```
All the benchmarks come with an associated benchmark dataset stored in [LangSmith](https://smith.langchain.com). To take advantage of the eval and debugging experience, [sign up](https://smith.langchain.com), and set your API key in your environment:
```bash
export LANGCHAIN_API_KEY=ls-...
```
## Repo Structure
The package is located within [langchain_benchmarks](./langchain_benchmarks/). Check out the [docs](https://langchain-ai.github.io/langchain-benchmarks/index.html) for information on how to get starte.
The other directories are legacy and may be moved in the future.
## Archived
Below are archived benchmarks that require cloning this repo to run.
- [CSV Question Answering](https://github.com/langchain-ai/langchain-benchmarks/tree/main/csv-qa)
- [Extraction](https://github.com/langchain-ai/langchain-benchmarks/tree/main/extraction)
- [Q&A over the LangChain docs](https://github.com/langchain-ai/langchain-benchmarks/tree/main/langchain-docs-benchmarking)
- [Meta-evaluation of 'correctness' evaluators](https://github.com/langchain-ai/langchain-benchmarks/tree/main/meta-evals)
## Related
- For cookbooks on other ways to test, debug, monitor, and improve your LLM applications, check out the [LangSmith docs](https://docs.smith.langchain.com/)
- For information on building with LangChain, check out the [python documentation](https://python.langchain.com/docs/get_started/introduction) or [JS documentation](https://js.langchain.com/docs/get_started/introduction)
@@ -5,7 +5,6 @@ from langchain.agents.agent_toolkits.conversational_retrieval.tool import (
)
from langchain.embeddings import OpenAIEmbeddings
from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate
from langchain.smith import RunEvalConfig, run_on_dataset
from langchain.tools import PythonAstREPLTool
from langchain.vectorstores import FAISS
@@ -1,6 +1,4 @@
import pandas as pd
from langchain.agents.agent_toolkits import create_pandas_dataframe_agent
from langchain.agents.agent_types import AgentType
from langchain.chat_models import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from langchain.schema.output_parser import StrOutputParser

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

@@ -1,8 +1,7 @@
from chat_langchain.chain import chain
from fastapi import FastAPI
from openai_functions_agent import agent_executor as openai_functions_agent_chain
from langserve import add_routes
from openai_functions_agent import agent_executor as openai_functions_agent_chain
app = FastAPI()
@@ -134,7 +134,7 @@ def create_response_chain(
]
)
response_synthesizer = (prompt | llm | StrOutputParser()).with_config(
response_generator = (prompt | llm | StrOutputParser()).with_config(
run_name="GenerateResponse",
)
return (
@@ -147,7 +147,7 @@ def create_response_chain(
),
}
| _context
| response_synthesizer
| response_generator
)
@@ -0,0 +1,57 @@
"""Copy the public dataset to your own langsmith tenant."""
from typing import Optional
from langsmith import Client
DATASET_NAME = "LangChain Docs Q&A"
PUBLIC_DATASET_TOKEN = "452ccafc-18e1-4314-885b-edd735f17b9d"
def create_langchain_docs_dataset(
dataset_name: str = DATASET_NAME,
public_dataset_token: str = PUBLIC_DATASET_TOKEN,
client: Optional[Client] = None,
):
shared_client = Client(
api_url="https://api.smith.langchain.com", api_key="placeholder"
)
examples = list(shared_client.list_shared_examples(public_dataset_token))
client = client or Client()
if client.has_dataset(dataset_name=dataset_name):
loaded_examples = list(client.list_examples(dataset_name=dataset_name))
if len(loaded_examples) == len(examples):
return
else:
ds = client.read_dataset(dataset_name=dataset_name)
else:
ds = client.create_dataset(dataset_name=dataset_name)
client.create_examples(
inputs=[e.inputs for e in examples],
outputs=[e.outputs for e in examples],
dataset_id=ds.id,
)
print("Done creating dataset.")
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--target-api-key", type=str, required=False)
parser.add_argument("--target-endpoint", type=str, required=False)
parser.add_argument("--dataset-name", type=str, default=DATASET_NAME)
parser.add_argument(
"--public-dataset-token", type=str, default=PUBLIC_DATASET_TOKEN
)
args = parser.parse_args()
client = None
if args.target_api_key or args.target_endpoint:
client = Client(
api_key=args.target_api_key,
api_url=args.target_endpoint,
)
create_langchain_docs_dataset(
dataset_name=args.dataset_name,
public_dataset_token=args.public_dataset_token,
client=client,
)
@@ -1,6 +1,5 @@
import argparse
import importlib.util
import os
import sys
import uuid
from functools import partial
@@ -120,6 +120,7 @@ if __name__ == "__main__":
]
for experiment in selected_experiments:
print("Running experiment:", experiment)
main(
**experiment,
dataset_name=args.dataset_name,
+20
View File
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+35
View File
@@ -0,0 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)
if "%1" == "" goto help
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd
+3
View File
@@ -0,0 +1,3 @@
chromadb/
index.md
Untitled.ipynb
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

+113
View File
@@ -0,0 +1,113 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------
import pathlib
import sys
from typing import List
import toml
ROOT_FOLDER = str(pathlib.Path(__file__).parent.parent.parent)
# Add the project root to the path
sys.path.insert(0, ROOT_FOLDER)
with open("../../pyproject.toml") as f:
data = toml.load(f)
project = "LangChain Benchmarks"
copyright = "2023, Langchain AI"
author = "Langchain AI"
version = data["tool"]["poetry"]["version"]
release = version
html_title = project + " " + version
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autodoc.typehints",
"sphinx.ext.autosummary",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"myst_nb",
"sphinx_copybutton",
"IPython.sphinxext.ipython_console_highlighting",
]
source_suffix = [".ipynb", ".html", ".md", ".rst"]
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns: List[str] = []
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_book_theme"
html_theme_options = {
"path_to_docs": "docs/source",
"repository_url": "https://github.com/langchain-ai/langchain-benchmarks",
"home_page_in_toc": True,
"show_navbar_depth": 2,
"use_sidenotes": True,
"use_repository_button": True,
"use_issues_button": True,
"use_source_button": True,
"use_fullscreen_button": True,
"repository_branch": "main",
"launch_buttons": {
"notebook_interface": "jupyterlab",
"colab_url": "https://colab.research.google.com",
},
}
html_context = {
"display_github": True, # Integrate GitHub
"github_user": "langchain-ai", # Username
"github_repo": "langchain-benchmarks", # Repo name
"github_version": "main", # Version
"conf_py_path": "/docs/", # Path in the checkout to the docs root
}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
# These paths are either relative to html_static_path
# or fully qualified paths (eg. https://...)
html_css_files = [
"css/custom.css",
]
nb_execution_mode = "off"
autosummary_generate = True
+225
View File
@@ -0,0 +1,225 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "033684fb-65b2-4586-a959-68c614741ca2",
"metadata": {},
"source": [
"# Datasets\n",
"[![Open In Collab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/langchain-ai/langchain-benchmarks/blob/main/docs/source/notebooks/datasets.ipynb)\n",
"\n",
"Here, we'll see how to work with LangSmith datasets."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%pip install -U langchain-benchmarks"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "6d272fbf-710e-4a49-a0da-67e010541905",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from langchain_benchmarks import clone_public_dataset, download_public_dataset"
]
},
{
"cell_type": "markdown",
"id": "18ee0f96-e5c4-4ae9-aebf-7d8b88c51662",
"metadata": {},
"source": [
"Let's first download the dataset to the local file system"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "58b94f6d-0c91-4361-9b22-f758ffaa150a",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fetching examples...\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5a2fad8c0c3549ec96a3b38fe8a002b0",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/21 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Done fetching examples.\n"
]
}
],
"source": [
"download_public_dataset(\n",
" \"https://smith.langchain.com/public/452ccafc-18e1-4314-885b-edd735f17b9d/examples\"\n",
")"
]
},
{
"cell_type": "markdown",
"id": "841db832-b0d3-4fd1-8531-1154ec9b3caa",
"metadata": {},
"source": [
"we can take a look at the first two examples"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "664e90fc-af84-4c5f-a3dd-5d9ffe649650",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[\n",
" {\n",
" \"created_at\": \"2023-11-15T15:26:53.511629\",\n",
" \"dataset_id\": \"9f73165c-d333-4d14-8f59-bd7eede5db08\",\n",
" \"id\": \"0703a989-2693-4039-a1f6-7281fc1b4cb0\",\n",
" \"inputs\": {\n",
" \"question\": \"do bob and alice live in the same city?\"\n",
" },\n",
" \"modified_at\": \"2023-11-15T15:26:53.511629\",\n",
" \"outputs\": {\n",
" \"expected_steps\": [\n",
" \"find_users_by_name\",\n",
" \"get_user_location\",\n",
" \"get_city_for_location\",\n",
" \"get_user_location\",\n",
" \"get_city_for_location\"\n",
" ],\n",
" \"order_matters\": false,\n",
" \"reference\": \"no\"\n",
" },\n",
" \"runs\": []\n",
" },\n",
" {\n",
" \"created_at\": \"2023-11-15T15:26:53.491359\",\n",
" \"dataset_id\": \"9f73165c-d333-4d14-8f59-bd7eede5db08\",\n",
" \"id\": \"b258b95a-9524-4da7-b758-c5481109322d\",\n",
" \"inputs\": {\n",
" \"question\": \"Is it likely that Donna is outside with an umbrella at this time?\"\n",
" },\n",
" \"modified_at\": \"2023-11-15T15:26:53.491359\",\n",
" \"outputs\": {\n",
" \"expected_steps\": [\n",
" \"find_users_by_name\",\n",
" \"get_user_location\",\n",
" \"get_current_time_for_location\",\n",
" \"get_current_weather_for_location\"\n",
" ],\n",
" \"order_matters\": false,\n",
" \"reference\": \"yes\"\n",
" },\n",
" \"runs\": []\n",
" }\n",
"]\n"
]
}
],
"source": [
"import json\n",
"\n",
"with open(\"./e95d45da-aaa3-44b3-ba2b-7c15ff6e46f5.json\", \"r\", encoding=\"utf-8\") as f:\n",
" print(json.dumps(json.load(f)[:2], indent=2, sort_keys=True))"
]
},
{
"cell_type": "markdown",
"id": "2c6cf01f-466b-406d-b4c7-2395747780fd",
"metadata": {},
"source": [
"We can also clone the dataset to our local tenant"
]
},
{
"cell_type": "markdown",
"id": "e4dea4df-2f1c-436b-a71c-49ffb2295ccc",
"metadata": {},
"source": [
"Executing this command will clone the dataset to your own LangSmith tenant. \n",
"For this to work you must have a [LangSmith account](https://smith.langchain.com/) set up."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"# Get from https://smith.langchain.com/settings\n",
"os.environ[\"LANGCHAIN_API_KEY\"] = \"ls_...\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "18d0b905-2a6a-4752-a7cb-8653bd9049e3",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"clone_public_dataset(\n",
" \"https://smith.langchain.com/public/452ccafc-18e1-4314-885b-edd735f17b9d/examples\",\n",
" dataset_name=\"Agent Dataset\",\n",
")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More