Skip to main content

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(
    # Can optionally pass in custom embedding model and LLM here.
)
search_term = video_index.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

youtube_qa-1.0.3.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

youtube_qa-1.0.3-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file youtube_qa-1.0.3.tar.gz.

File metadata

  • Download URL: youtube_qa-1.0.3.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for youtube_qa-1.0.3.tar.gz
Algorithm Hash digest
SHA256 5d1f793bb2fee57bb477df54e13b42efc7134d403650db41d53f657451d3e979
MD5 f0ab431fa2e10778925725285aac1687
BLAKE2b-256 7e04bb25d0d2d11aa73e72009bb9c44f470b5447e7ca3d1a61fac8fe56ab3fc5

See more details on using hashes here.

Provenance

File details

Details for the file youtube_qa-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: youtube_qa-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for youtube_qa-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e74986e1a1a42e99c209b88e61604e1ed88118ea2478245bf4019a576d7a2152
MD5 1e3a7f1a0fbab5eebbd6b075e0b14c22
BLAKE2b-256 f061d32aa610929c562774cd4aa46c0b3cea858440b43d875c3296fcad909f24

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page