Skip to content

Commit

Permalink
Logan/merge next (run-llama#10676)
Browse files Browse the repository at this point in the history
  • Loading branch information
logan-markewich authored and Dominastorm committed Feb 28, 2024
1 parent 80b8879 commit 03f32e0
Show file tree
Hide file tree
Showing 73 changed files with 7,944 additions and 742 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ jobs:
with:
# v0 makes it easy to bust the cache if needed
# just increase the integer to start with a fresh cache
gha-cache-key: v0-py${{ matrix.python_version }}
named-caches-hash: v0-py${{ matrix.python_version }}
gha-cache-key: v1-py${{ matrix.python_version }}
named-caches-hash: v1-py${{ matrix.python_version }}
pants-python-version: ${{ matrix.python-version }}
pants-ci-config: pants.toml
- name: Check BUILD files
Expand Down
87 changes: 30 additions & 57 deletions docs/examples/evaluation/faithfulness_eval.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"metadata": {},
"outputs": [],
"source": [
"%pip install llama-index-llms-openai"
"%pip install llama-index-llms-openai pandas[jinja2] spacy"
]
},
{
Expand All @@ -38,16 +38,13 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9080b39e",
"id": "190a6684",
"metadata": {},
"outputs": [],
"source": [
"# configuring logger to INFO level\n",
"import logging\n",
"import sys\n",
"import os\n",
"\n",
"logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n",
"logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))"
"os.environ[\"OPENAI_API_KEY\"] = \"sk-...\""
]
},
{
Expand All @@ -58,7 +55,6 @@
"outputs": [],
"source": [
"from llama_index.core import (\n",
" TreeIndex,\n",
" VectorStoreIndex,\n",
" SimpleDirectoryReader,\n",
" Response,\n",
Expand Down Expand Up @@ -123,8 +119,11 @@
"metadata": {},
"outputs": [],
"source": [
"from llama_index.core.evaluation import EvaluationResult\n",
"\n",
"\n",
"# define jupyter display function\n",
"def display_eval_df(response: Response, eval_result: str) -> None:\n",
"def display_eval_df(response: Response, eval_result: EvaluationResult) -> None:\n",
" if response.source_nodes == []:\n",
" print(\"no response!\")\n",
" return\n",
Expand All @@ -133,6 +132,7 @@
" \"Response\": str(response),\n",
" \"Source\": response.source_nodes[0].node.text[:1000] + \"...\",\n",
" \"Evaluation Result\": \"Pass\" if eval_result.passing else \"Fail\",\n",
" \"Reasoning\": eval_result.feedback,\n",
" },\n",
" index=[0],\n",
" )\n",
Expand Down Expand Up @@ -176,32 +176,34 @@
"data": {
"text/html": [
"<style type=\"text/css\">\n",
"#T_db5e8_row0_col0, #T_db5e8_row0_col1 {\n",
"#T_21e1a_row0_col0, #T_21e1a_row0_col1 {\n",
" inline-size: 600px;\n",
" overflow-wrap: break-word;\n",
"}\n",
"</style>\n",
"<table id=\"T_db5e8\">\n",
"<table id=\"T_21e1a\">\n",
" <thead>\n",
" <tr>\n",
" <th class=\"blank level0\" >&nbsp;</th>\n",
" <th id=\"T_db5e8_level0_col0\" class=\"col_heading level0 col0\" >Response</th>\n",
" <th id=\"T_db5e8_level0_col1\" class=\"col_heading level0 col1\" >Source</th>\n",
" <th id=\"T_db5e8_level0_col2\" class=\"col_heading level0 col2\" >Evaluation Result</th>\n",
" <th id=\"T_21e1a_level0_col0\" class=\"col_heading level0 col0\" >Response</th>\n",
" <th id=\"T_21e1a_level0_col1\" class=\"col_heading level0 col1\" >Source</th>\n",
" <th id=\"T_21e1a_level0_col2\" class=\"col_heading level0 col2\" >Evaluation Result</th>\n",
" <th id=\"T_21e1a_level0_col3\" class=\"col_heading level0 col3\" >Reasoning</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th id=\"T_db5e8_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n",
" <td id=\"T_db5e8_row0_col0\" class=\"data row0 col0\" >New York City got its name from the English explorer Henry Hudson, who rediscovered New York Harbor in 1609 while searching for the Northwest Passage. He named the area New York after the Duke of York, who later became King James II of England.</td>\n",
" <td id=\"T_db5e8_row0_col1\" class=\"data row0 col1\" >He claimed the area for France and named it Nouvelle Angoulême (New Angoulême).A Spanish expedition, led by the Portuguese captain Estêvão Gomes sailing for Emperor Charles V, arrived in New York Harbor in January 1525 and charted the mouth of the Hudson River, which he named Río de San Antonio ('Saint Anthony's River').The Padrón Real of 1527, the first scientific map to show the East Coast of North America continuously, was informed by Gomes' expedition and labeled the northeastern United States as Tierra de Esteban Gómez in his honor.In 1609, the English explorer Henry Hudson rediscovered New York Harbor while searching for the Northwest Passage to the Orient for the Dutch East India Company.He proceeded to sail up what the Dutch would name the North River (now the Hudson River), named first by Hudson as the Mauritius after Maurice, Prince of Orange.Hudson's first mate described the harbor as \"a very good Harbour for all windes\" and the river as \"a mile broad\" and \"full of fish\".Hud...</td>\n",
" <td id=\"T_db5e8_row0_col2\" class=\"data row0 col2\" >Fail</td>\n",
" <th id=\"T_21e1a_level0_row0\" class=\"row_heading level0 row0\" >0</th>\n",
" <td id=\"T_21e1a_row0_col0\" class=\"data row0 col0\" >New York City got its name when it came under British control in 1664. It was renamed New York after King Charles II of England granted the lands to his brother, the Duke of York.</td>\n",
" <td id=\"T_21e1a_row0_col1\" class=\"data row0 col1\" >The city came under British control in 1664 and was renamed New York after King Charles II of England granted the lands to his brother, the Duke of York. The city was regained by the Dutch in July 1673 and was renamed New Orange for one year and three months; the city has been continuously named New York since November 1674. New York City was the capital of the United States from 1785 until 1790, and has been the largest U.S. city since 1790. The Statue of Liberty greeted millions of immigrants as they came to the U.S. by ship in the late 19th and early 20th centuries, and is a symbol of the U.S. and its ideals of liberty and peace. In the 21st century, New York City has emerged as a global node of creativity, entrepreneurship, and as a symbol of freedom and cultural diversity. The New York Times has won the most Pulitzer Prizes for journalism and remains the U.S. media's \"newspaper of record\". In 2019, New York City was voted the greatest city in the world in a survey of over 30,000 p...</td>\n",
" <td id=\"T_21e1a_row0_col2\" class=\"data row0 col2\" >Pass</td>\n",
" <td id=\"T_21e1a_row0_col3\" class=\"data row0 col3\" >YES</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n"
],
"text/plain": [
"<pandas.io.formats.style.Styler at 0x7f991be1bc40>"
"<pandas.io.formats.style.Styler at 0x169353d10>"
]
},
"metadata": {},
Expand Down Expand Up @@ -229,22 +231,23 @@
"metadata": {},
"outputs": [
{
"name": "stdout",
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:llama_index.indices.service_context:chunk_size_limit is deprecated, please specify chunk_size instead\n",
"chunk_size_limit is deprecated, please specify chunk_size instead\n",
"chunk_size_limit is deprecated, please specify chunk_size instead\n"
"/Users/loganmarkewich/giant_change/llama_index/llama-index-core/llama_index/core/evaluation/dataset_generation.py:212: DeprecationWarning: Call to deprecated class DatasetGenerator. (Deprecated in favor of `RagDatasetGenerator` which should be used instead.)\n",
" return cls(\n",
"/Users/loganmarkewich/giant_change/llama_index/llama-index-core/llama_index/core/evaluation/dataset_generation.py:309: DeprecationWarning: Call to deprecated class QueryResponseDataset. (Deprecated in favor of `LabelledRagDataset` which should be used instead.)\n",
" return QueryResponseDataset(queries=queries, responses=responses_dict)\n"
]
},
{
"data": {
"text/plain": [
"['What is the population of New York City as of 2020?',\n",
" 'Which borough of New York City is home to the headquarters of the United Nations?',\n",
" 'How many languages are spoken in New York City, making it the most linguistically diverse city in the world?',\n",
" 'Who founded the trading post on Manhattan Island that would later become New York City?',\n",
" 'What was New York City named after in 1664?']"
" 'Which city is the second-largest in the United States?',\n",
" 'How many people live within 250 miles of New York City?',\n",
" 'What are the five boroughs of New York City?',\n",
" 'What is the gross metropolitan product of the New York metropolitan area?']"
]
},
"execution_count": null,
Expand Down Expand Up @@ -297,36 +300,6 @@
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:openai:message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=35 request_id=b36e17a843c31e827f0b7034e603cf28 response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=35 request_id=b36e17a843c31e827f0b7034e603cf28 response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=35 request_id=b36e17a843c31e827f0b7034e603cf28 response_code=200\n",
"INFO:openai:message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=35 request_id=5acb726518065db9312da9f23beef411 response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=35 request_id=5acb726518065db9312da9f23beef411 response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=35 request_id=5acb726518065db9312da9f23beef411 response_code=200\n",
"INFO:openai:message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=46 request_id=4af43bfbe4e24fdae0ec33312ee7491e response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=46 request_id=4af43bfbe4e24fdae0ec33312ee7491e response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=46 request_id=4af43bfbe4e24fdae0ec33312ee7491e response_code=200\n",
"INFO:openai:message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=37 request_id=e30413546fe5f96d3890606767f2ec53 response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=37 request_id=e30413546fe5f96d3890606767f2ec53 response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=37 request_id=e30413546fe5f96d3890606767f2ec53 response_code=200\n",
"INFO:openai:message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=33 request_id=01f0a8dada4dae80c97a9a412f03b84f response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=33 request_id=01f0a8dada4dae80c97a9a412f03b84f response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=33 request_id=01f0a8dada4dae80c97a9a412f03b84f response_code=200\n",
"INFO:openai:message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=282 request_id=ed7b1f8ba68ae32b1d8e24e0d0764e86 response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=282 request_id=ed7b1f8ba68ae32b1d8e24e0d0764e86 response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=282 request_id=ed7b1f8ba68ae32b1d8e24e0d0764e86 response_code=200\n",
"INFO:openai:message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=820 request_id=b4532c6d665b6cfd644861ed69819cb9 response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=820 request_id=b4532c6d665b6cfd644861ed69819cb9 response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=820 request_id=b4532c6d665b6cfd644861ed69819cb9 response_code=200\n",
"INFO:openai:message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=847 request_id=4d9bbc71a95b7e0bb69a048e251772c8 response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=847 request_id=4d9bbc71a95b7e0bb69a048e251772c8 response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=847 request_id=4d9bbc71a95b7e0bb69a048e251772c8 response_code=200\n",
"INFO:openai:message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=952 request_id=d1657940d881929d500b1fddc46b5866 response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=952 request_id=d1657940d881929d500b1fddc46b5866 response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=952 request_id=d1657940d881929d500b1fddc46b5866 response_code=200\n",
"INFO:openai:message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=1482 request_id=c4456f75580d227f846d3a044e5eef1b response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=1482 request_id=c4456f75580d227f846d3a044e5eef1b response_code=200\n",
"message='OpenAI API response' path=https://api.openai.com/v1/chat/completions processing_ms=1482 request_id=c4456f75580d227f846d3a044e5eef1b response_code=200\n",
"finished query\n",
"score: 5/5\n"
]
Expand Down
Loading

0 comments on commit 03f32e0

Please sign in to comment.