Learn Data With Mark

repository·main·Indexed 42 days ago

https://github.com/mneedham/learndatawithmark

A collection of AI playgrounds and tools for analyzing YouTube comments, clustering data, and structured information extraction. Includes implementations for Chainlit chatbots, Guidance AI, LLaVA with llamafile, LLMware SLIM models, Docling for Markdown conversion, mlx_whisper for transcription, and NuExtract for JSON-based extraction via Ollama.

Tokens
32.1K
Snippets
122
Records
149
Agent score
52%

What's inside Learn Data With Mark

  1. Overview of Consistent JSON with OpenAI/GPT

    main
    This project provides methods for ensuring consistent JSON output when interacting with OpenAI or GPT models. It addresses the common challenge of LLMs returning malformed or non-compliant JSON by providing structured prompting or parsing techniques to guarantee valid JSON responses for downstream application use.
  2. Analyze and cluster YouTube comments with the Streamlit app

    main
    This project provides a Streamlit application designed to analyze and cluster YouTube comments for a specific video. It leverages local embeddings via Ollama to perform clustering tasks. For a detailed walkthrough of the underlying logic and implementation, refer to the author's blog post: https://www.markhneedham.com/blog/2024/02/27/clustering-youtube-comments-ollama-embeddings-nomic/
  3. Chatbot implementation variations

    main

    The project provides several stages of chatbot implementation, ranging from simple echo bots to advanced RAG-capable assistants:

    • chat_echo.py: A basic bot that echos back any messages sent to it.
    • chat_single.py: Answers questions using an LLM but does not maintain conversation history.
    • chat_history.py: Answers questions and maintains chat history for context.
    • chat.py: The complete implementation that answers questions, remembers history, and supports answering questions based on uploaded text files.
  4. Leverage predicate pushdown with nested structs

    main

    DuckDB 1.2 supports predicate pushdown on nested struct fields. This means when querying datasets (like Parquet files or JSON files), filters applied to nested fields (e.g., json.field.subfield = 'value') can be pushed down to the storage layer to optimize performance. This is particularly effective when querying Parquet files exported from JSON data.

    -- Example of filtering on nested struct fields in a Parquet file
    FROM 'events.parquet'
    SELECT json.pass.recipient.name, count()
    WHERE
      json.pass.height.name = 'High Pass'
    AND
      json.pass.outcome.name = 'Incomplete'
    AND 
      json.possession_team.name = 'Japan'
    AND
      json.pass.recipient.name NOT NULL
    GROUP BY ALL
    ORDER BY count() DESC
    LIMIT 5;
  5. Run the Jupyter Lab notebooks in llm-own-laptop

    main

    To launch the Jupyter Lab environment for this project, use poetry run to ensure all dependencies are managed within the Poetry virtual environment. Use the --notebook-dir flag to specify the notebooks directory as the root for your workspace.

    poetry run jupyter lab --notebook-dir notebooks
  6. Constrain LLMs using Guidance AI

    main

    Use the Guidance library to control and constrain text generation from large language models. This implementation integrates with the llama CPP library and the Mistral 7B model. Key capabilities include:

    • Using select to restrict generation to a specific array of values.
    • Using gen to control generation via regular expressions.
    • Creating reusable components and forcing outputs into JSON format.
  7. Generate consistent JSON responses with OpenAI/GPT

    main
    Learn how to constrain OpenAI/GPT models to return predictable, valid, and consistent JSON structures. This is particularly useful for tasks like sentiment analysis where the output must be parsed programmatically by downstream applications.
  8. Set up Retrieval Augmented Generation with OpenAI and Chroma

    main

    This project demonstrates how to implement Retrieval Augmented Generation (RAG) using LangChain, Chroma (a vector database), and OpenAI/GPT models. The goal is to provide an LLM with additional context (e.g., data about the Wimbledon 2023 tennis tournament) to improve answer accuracy.

    To use this project, you must configure your OpenAI API key and install the necessary dependencies using Poetry.

  9. Define structs in DuckDB 1.2

    main

    In DuckDB 1.2, you can define structs using the SET VARIABLE command with a JSON-like dictionary syntax. This allows you to store complex objects in session variables for later use.

    SET VARIABLE struct1 = {'name': 'DuckDB', 'firstRelease': 2019};
    SET VARIABLE struct2 = {'description': 'in-process SQL database'};
  10. Convert a webpage to Markdown using Docling

    main

    You can use the docling tool via uv to convert a Wikipedia page (or any URL) into a structured Markdown file. This is useful for preparing data for LLM analysis.

    uv run --with docling --with numpy==1.26.4 \
    docling \
    https://en.wikipedia.org/wiki/Novak_Djokovic_career_statistics