harrison/combine-docs-parse
Harrison Chase 1 year ago
parent 01d1b05edf
commit e98f4c8891

@ -95,18 +95,18 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"id": "7d766417",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'answer': ' The president did not mention Justice Breyer.',\n",
" 'sources': '0-pl, 1-pl, 2-pl'}"
"{'answer': ' The president thanked Justice Breyer for his service.',\n",
" 'sources': '30-pl'}"
]
},
"execution_count": 7,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@ -128,7 +128,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"id": "921db0a4",
"metadata": {},
"outputs": [],
@ -138,18 +138,18 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"id": "e417926a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'answer': ' The president did not mention Justice Breyer.',\n",
" 'sources': '0, 1, 2'}"
"{'answer': ' The president thanked Justice Breyer for his service.',\n",
" 'sources': '30-pl'}"
]
},
"execution_count": 9,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
@ -171,7 +171,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"id": "15af265f",
"metadata": {},
"outputs": [],
@ -181,18 +181,21 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"id": "21b136e5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'map_steps': [' None', ' None', ' None'],\n",
" 'output_text': ' The president did not mention Justice Breyer.\\nSOURCES: 0, 1, 2'}"
"{'map_steps': [' \"Tonight, Id like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service.\"',\n",
" ' None',\n",
" ' None',\n",
" ' None'],\n",
" 'output_text': ' The president thanked Justice Breyer for his service.\\nSOURCES: 30-pl'}"
]
},
"execution_count": 11,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
@ -213,7 +216,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"id": "904835c8",
"metadata": {},
"outputs": [],
@ -223,18 +226,18 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 12,
"id": "f60875c6",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'answer': \"\\n\\nThe president did not mention Justice Breyer in his speech to the European Parliament. He spoke about the struggle of the Ukrainian people, the importance of the NATO Alliance, and the need for American diplomacy and resolve. He discussed Putin's premeditated and unprovoked attack on Ukraine, and the efforts to build a coalition of freedom-loving nations to confront Putin. He also discussed how the free world is holding Putin accountable, and the countries that are part of the coalition, including France, Germany, Italy, the United Kingdom, Canada, Japan, Korea, Australia, New Zealand, and Switzerland. Source: 1, 2\",\n",
"{'answer': \"\\n\\nThe president said that he was honoring Justice Breyer for his dedication to serving the country and that he was a retiring Justice of the United States Supreme Court. He also thanked him for his service and praised his career as a top litigator in private practice, a former federal public defender, and a family of public school educators and police officers. He noted Justice Breyer's reputation as a consensus builder and the broad range of support he has received from the Fraternal Order of Police to former judges appointed by Democrats and Republicans. He also highlighted the importance of securing the border and fixing the immigration system in order to advance liberty and justice, and mentioned the new technology, joint patrols, dedicated immigration judges, and commitments to support partners in South and Central America that have been put in place. He also expressed his commitment to the LGBTQ+ community, noting the need for the bipartisan Equality Act and the importance of protecting transgender Americans from state laws targeting them. He also highlighted his commitment to bipartisanship, noting the 80 bipartisan bills he signed into law last year, and his plans to strengthen the Violence Against Women Act. Additionally, he announced that the Justice Department will name a chief prosecutor for pandemic fraud and his plan to lower the deficit by more than one trillion dollars in a\",\n",
" 'sources': ''}"
]
},
"execution_count": 15,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
@ -256,7 +259,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 13,
"id": "3396a773",
"metadata": {},
"outputs": [],
@ -266,20 +269,21 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 14,
"id": "be5739ef",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'refine_steps': ['\\nThe president did not mention Justice Breyer in the given context.',\n",
" '\\n\\nThe president did not mention Justice Breyer in his speech to the European Parliament. He spoke about the struggle of the Ukrainian people, the importance of the NATO Alliance, and the need for American diplomacy and resolve. Source: 1',\n",
" \"\\n\\nThe president did not mention Justice Breyer in his speech to the European Parliament. He spoke about the struggle of the Ukrainian people, the importance of the NATO Alliance, and the need for American diplomacy and resolve. He discussed Putin's premeditated and unprovoked attack on Ukraine, and the efforts to build a coalition of freedom-loving nations to confront Putin. He also discussed how the free world is holding Putin accountable, and the countries that are part of the coalition, including France, Germany, Italy, the United Kingdom, Canada, Japan, Korea, Australia, New Zealand, and Switzerland. Source: 1, 2\"],\n",
" 'output_text': \"\\n\\nThe president did not mention Justice Breyer in his speech to the European Parliament. He spoke about the struggle of the Ukrainian people, the importance of the NATO Alliance, and the need for American diplomacy and resolve. He discussed Putin's premeditated and unprovoked attack on Ukraine, and the efforts to build a coalition of freedom-loving nations to confront Putin. He also discussed how the free world is holding Putin accountable, and the countries that are part of the coalition, including France, Germany, Italy, the United Kingdom, Canada, Japan, Korea, Australia, New Zealand, and Switzerland. Source: 1, 2\"}"
"{'refine_steps': ['\\nThe president said that he was honoring Justice Breyer for his dedication to serving the country and that he was a veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court.',\n",
" '\\n\\nThe president said that he was honoring Justice Breyer for his dedication to serving the country, his experience as a veteran, Constitutional scholar, former top litigator in private practice, former federal public defender, and retiring Justice of the United States Supreme Court. He also noted that Justice Breyer came from a family of public school educators and police officers, and that he was a consensus builder who had received a broad range of support from the Fraternal Order of Police to former judges appointed by Democrats and Republicans. The president also highlighted his commitment to advancing liberty and justice by securing the border and fixing the immigration system, including installing new technology, setting up joint patrols with Mexico and Guatemala, putting in place dedicated immigration judges, and securing commitments and supporting partners in South and Central America. Source: 31',\n",
" '\\n\\nThe president said that he was honoring Justice Breyer for his dedication to serving the country, his experience as a veteran, Constitutional scholar, former top litigator in private practice, former federal public defender, and retiring Justice of the United States Supreme Court. He also noted that Justice Breyer came from a family of public school educators and police officers, and that he was a consensus builder who had received a broad range of support from the Fraternal Order of Police to former judges appointed by Democrats and Republicans. The president also highlighted his commitment to advancing liberty and justice by securing the border and fixing the immigration system, including installing new technology, setting up joint patrols with Mexico and Guatemala, putting in place dedicated immigration judges, and securing commitments and supporting partners in South and Central America. He also expressed his commitment to the LGBTQ+ community by offering a Unity Agenda for the Nation, which includes beating the opioid epidemic, and passing the bipartisan Equality Act. Source: 31, 33',\n",
" '\\n\\nThe president said that he was honoring Justice Breyer for his dedication to serving the country, his experience as a veteran, Constitutional scholar, former top litigator in private practice, former federal public defender, and retiring Justice of the United States Supreme Court. He also noted that Justice Breyer came from a family of public school educators and police officers, and that he was a consensus builder who had received a broad range of support from the Fraternal Order of Police to former judges appointed by Democrats and Republicans. The president also highlighted his commitment to advancing liberty and justice by securing the border and fixing the immigration system, including installing new technology, setting up joint patrols with Mexico and Guatemala, putting in place dedicated immigration judges, and securing commitments and supporting partners in South and Central America. He also expressed his commitment to the LGBTQ+ community by offering a Unity Agenda for the Nation, which includes beating the opioid epidemic, and passing the bipartisan Equality Act. Additionally, the president mentioned his plan to lower costs to give families a fair shot, lower the deficit, and go after criminals who stole billions in relief money meant for small businesses and millions of Americans. He also announced that the Justice Department will name a chief prosecutor for pandemic fraud. Source: 20, 31, 33'],\n",
" 'output_text': '\\n\\nThe president said that he was honoring Justice Breyer for his dedication to serving the country, his experience as a veteran, Constitutional scholar, former top litigator in private practice, former federal public defender, and retiring Justice of the United States Supreme Court. He also noted that Justice Breyer came from a family of public school educators and police officers, and that he was a consensus builder who had received a broad range of support from the Fraternal Order of Police to former judges appointed by Democrats and Republicans. The president also highlighted his commitment to advancing liberty and justice by securing the border and fixing the immigration system, including installing new technology, setting up joint patrols with Mexico and Guatemala, putting in place dedicated immigration judges, and securing commitments and supporting partners in South and Central America. He also expressed his commitment to the LGBTQ+ community by offering a Unity Agenda for the Nation, which includes beating the opioid epidemic, and passing the bipartisan Equality Act. Additionally, the president mentioned his plan to lower costs to give families a fair shot, lower the deficit, and go after criminals who stole billions in relief money meant for small businesses and millions of Americans. He also announced that the Justice Department will name a chief prosecutor for pandemic fraud. Source: 20, 31, 33'}"
]
},
"execution_count": 17,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}

@ -26,7 +26,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"id": "17d1306e",
"metadata": {},
"outputs": [],
@ -41,7 +41,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "0e745d99",
"metadata": {},
"outputs": [],
@ -51,7 +51,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"id": "f42d79dc",
"metadata": {},
"outputs": [],
@ -63,7 +63,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"id": "8aa571ae",
"metadata": {},
"outputs": [],
@ -73,7 +73,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 6,
"id": "aa859d4c",
"metadata": {},
"outputs": [],
@ -85,7 +85,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 7,
"id": "8ba36fa7",
"metadata": {},
"outputs": [
@ -96,7 +96,7 @@
" 'sources': '30-pl'}"
]
},
"execution_count": 9,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
@ -104,11 +104,19 @@
"source": [
"chain({\"question\": \"What did the president say about Justice Breyer\"}, return_only_outputs=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9e8ded9a",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.0 64-bit ('llm-env')",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@ -122,7 +130,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.0"
"version": "3.10.9"
},
"vscode": {
"interpreter": {

@ -115,7 +115,7 @@ class BaseQAWithSourcesChain(Chain, BaseModel, ABC):
def _call(self, inputs: Dict[str, Any]) -> Dict[str, str]:
docs = self._get_docs(inputs)
answer, _ = self.combine_document_chain.combine_and_parse(docs, **inputs)
answer = self.combine_document_chain.combine_and_parse(docs, **inputs)
return answer

Loading…
Cancel
Save