Question answering over YouTube videos with embeddings and LLMs.
Project description
YouTube Question Answer
Simple experiment for question answering on YouTube videos using embeddings and the top n YouTube search result transcripts.
The function will take a question and optionally a YouTube search query (otherwise an LLM will auto-generate one), will compile transcripts for each video result, generate an embedding index using the transcripts and then answer the question using the relevant embeddings.
The function will return both a string response and a list of sources that were used for the answer.
Installation
The package can be installed from PyPI with pip install youtube-qa
. Make sure to set your OPENAI_API_KEY
environment variable before using.
Example
from youtube_qa.youtube_video_index import VideoIndexQueryResponse, YouTubeVideoIndex
video_index = YouTubeVideoIndex()
video_index.build_index(
search_term="huberman motivation",
video_results=3,
)
response: VideoIndexQueryResponse = video_index.answer_question(
question="what are the best researched supplements to help with exercise motivation",
)
print(response.answer) # The answer to the question.
print(response.sources) # Video links and other metadata.
You can also generate the search query given the question:
from youtube_qa.youtube_video_index import VideoIndexQueryResponse, YouTubeVideoIndex
question = "what are the best researched supplements to help with exercise motivation"
video_index = YouTubeVideoIndex()
search_term = generate_search_query(question)
video_index.build_index(
search_term=search_term,
video_results=3,
)
response: VideoIndexQueryResponse = video_index.answer_question(
question=question,
)
print(response.answer) # The answer to the question.
print(response.sources) # Video links and other metadata.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for youtube_qa-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6397f8f83bcab9a87a075edc5b1f2b0d350ff303e2b64f794d0eeb1ee1e8dcc |
|
MD5 | a5ec57a0ae5a1b65927ec78130be1917 |
|
BLAKE2b-256 | 3ffe3b324f4a03ef0a624bfc53a1754398cd7f0f1adb2f1579644b2d5ba7d55f |