• Stars
    star
    135
  • Rank 269,297 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created about 2 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A sandbox repo for grounded question answering with Cohere and Google Search
################################################################################
#    ____      _                     ____                  _ _                 #
#   / ___|___ | |__   ___ _ __ ___  / ___|  __ _ _ __   __| | |__   _____  __  #
#  | |   / _ \| '_ \ / _ \ '__/ _ \ \___ \ / _` | '_ \ / _` | '_ \ / _ \ \/ /  #
#  | |__| (_) | | | |  __/ | |  __/  ___) | (_| | | | | (_| | |_) | (_) >  <   #
#   \____\___/|_| |_|\___|_|  \___| |____/ \__,_|_| |_|\__,_|_.__/ \___/_/\_\  #
#                                                                              #
# This project is part of Cohere Sandbox, Cohere's Experimental Open Source    #
# offering. This project provides a library, tooling, or demo making use of    #
# the Cohere Platform. You should expect (self-)documented, high quality code  #
# but be warned that this is EXPERIMENTAL. Therefore, also expect rough edges, #
# non-backwards compatible changes, or potential changes in functionality as   #
# the library, tool, or demo evolves. Please consider referencing a specific   #
# git commit or version if depending upon the project in any mission-critical  #
# code as part of your own projects.                                           #
#                                                                              #
# Please don't hesitate to raise issues or submit pull requests, and thanks    #
# for checking out this project!                                               #
#                                                                              #
################################################################################

Maintainer: nickfrosst
Project maintained until at least (YYYY-MM-DD): 2023-01-01

Grounded Question Answering

This is a Cohere API / Serp API powered contextualized factual question answering bot!

It responds to question in discord or in the cli by understanding the context, google searching what it believes to be the appropriate question, finding relevant information on the google result pages and then answering the question based on what it found.

Motivation

Language models are very good at creating sensible answers to complex questions. They are not however very good at creating truthful answers. This is because language models don't have a mechanism for determining truth. They are trained on data from the web, and so pick up statistical correlations between words that make them ok at answering simple and static questions (things like "how far away is the moon from the earth", which has a single and unchanging factual answer), but more nuanced questions or that have factual answers which change over time (things like "who is the prime minister of the UK") are difficult or impossible for language models to answer.

Google search, on the other hand, is very good at retrieving factual information about these time-sensitive questions. Google makes use of a consensus mechanism for determining truth. Google search results are heavily affected by human user behaviour; which links people click, which links they stay on, and which ones they revisit all affect the ordering of the results. In this way, google determines which links are truthful through user consensus. Google however is quite poor at responding to contextual questions, and at responding to complex questions in natural language.

This project attempts to join the best of both of these methods; It uses Cohere's large language models to contextualize the given questions and create a natural language answer, but it uses google search as a source of truth.

Example

image

Overview Video

Here is a quick video demoing the project and talking about ways in which it can be improved.

Installation and Demo Use

To use this library, you will need:

  1. Clone the repository.
  2. Install all the dependencies
pip install -r requirements.txt
  1. Try the demo by running the cli tool
python3 cli_demo.py --cohere_api_key <API_KEY> --serp_api_key <API_KEY>

or with increased verbosity

python3 cli_demo.py --cohere_api_key <API_KEY> --serp_api_key <API_KEY> --verbosity 2
  1. (Optional) Run the discord bot demo:
    You can create a discord both with this functionality by creating a bot account with message read and write permissions at https://discord.com/developers then running the following command
python3 discord_bot.py --cohere_api_key <API_KEY> --serp_api_key <API_KEY> --discord_key <DISCORD_KEY>
  1. (Optional) Run the demo as REST based web service:
python3 rest_bot.py --cohere_api_key <API_KEY> --serp_api_key <API_KEY> --discord_key <DISCORD_KEY>

and send a request

curl --request POST --url http://localhost:5007/api/v1/ask --header 'content-type: application/json' --data '{ "question":"When was the fall of Constantinople?" }'

Get support

If you have any questions or comments, please file an issue or reach out to us on Discord.

Contributors

If you would like to contribute to this project, please read CONTRIBUTORS.md in this repository, and sign the Contributor License Agreement before submitting any pull requests. A link to sign the Cohere CLA will be generated the first time you make a pull request to a Cohere repository.

License

Grounded Question Answering has an MIT license, as found in the LICENSE file.

More Repositories

1

cohere-toolkit

Cohere Toolkit is a collection of prebuilt components enabling users to quickly build and deploy RAG applications.
TypeScript
2,814
star
2

notebooks

Code examples and jupyter notebooks for the Cohere Platform
Jupyter Notebook
472
star
3

cohere-python

Python Library for Accessing the Cohere API
Python
294
star
4

sandbox-topically

Topic modeling helpers using managed language models from Cohere. Name text clusters using large GPT models.
Jupyter Notebook
214
star
5

DiskVectorIndex

Python
202
star
6

BinaryVectorDB

Efficient vector database for hundred millions of embeddings.
Python
198
star
7

sandbox-conversant-lib

Conversational AI tooling & personas built on Cohere's LLMs
Python
173
star
8

cohere-terrarium

A simple Python sandbox for helpful LLM data agents
Python
153
star
9

quick-start-connectors

This open-source repository offers reference code for integrating workplace datastores with Cohere's LLMs, enabling developers and businesses to perform seamless retrieval-augmented generation (RAG) on their own data.
Python
140
star
10

magikarp

Python
125
star
11

cohere-typescript

The Cohere TypeScript SDK
TypeScript
124
star
12

sandbox-toy-semantic-search

A demonstration of how a toy (but usable!) semantic search engine can be quickly built using Cohere's platform.
Python
114
star
13

sandbox-multilingual

A demonstration of a multilingual semantic search engine you can be quickly built using Cohere's platform.
Python
59
star
14

cohere-aws

Jupyter Notebook
57
star
15

sandbox-accelerating-chatbot-training

Leveraging Cohere's models to enable zero-shot routing
Python
53
star
16

cohere-go

Go Library for Accessing the Cohere API
Go
45
star
17

samples

Sample integrations built by Cohere.
JavaScript
25
star
18

examples

Examples and Demos using the Cohere APIs
Jupyter Notebook
23
star
19

sandbox-condense

Webpage Summarizer
JavaScript
20
star
20

human-feedback-paper

Code and data from the paper 'Human Feedback is not Gold Standard'
Jupyter Notebook
18
star
21

public-demos

Public demos using the Cohere platform!
TypeScript
11
star
22

tokenizer

BPE tokenization implemented in Golang 💙
Go
10
star
23

cohere-java

Cohere's Java SDK
Java
7
star
24

cohere-developer-experience

Docs, Snippets, Guides
MDX
5
star
25

co

Cohere command line tool
Shell
3
star
26

cohere-compass-sdk

Provides an SDK for interacting with Compass, and Compass Parsing
Python
2
star
27

co-cli

Shell
1
star
28

cohere-ruby

Ruby
1
star