Learning LLMs and GenAI for Dev, Sec, and Ops

Dec 25, 2023 | Data Science

This guide will help you navigate through understanding LLMs (Large Language Models) and GenAI (Generative AI) from a developer, operations, and security perspective. This repository aims to organize essential lessons in a narrative format which makes it easier for traditional software engineers to grasp these advanced concepts.

What’s in the Repository?

The repository provides a structured approach to various information about LLMs and GenAI, particularly through the Langchain framework. It expects familiarity with Python programming and includes various practical examples, with due attribution. Let’s explore the lessons available:

Lessons Overview

  • Developer:
    • Calling a simple LLM using OpenAI
    • Debugging in Langchain
    • Chatting with OpenAI as model
    • Using prompt templates
    • Use of Docloader to read local files for LLM
    • Understanding embeddings and their calculations
    • Importance of splitting and chunking data
    • Loading embeddings in a vector database
    • Using chains for Questions and Answers to implement RAG (Retrieval Augmented Generation)
    • Using OpenAI documentation for real-time information generation
    • Implementing an Agent for real-time information retrieval
  • Operations:
    • Finding out token usage and cost
    • Caching LLM calls using exact matching or embeddings
    • Local caching of embeddings calculations
    • Running your local LLM using Ollama
    • Logging calls with callback handlers
    • Imposing output structure (JSON) and retrying on errors
  • Security:
    • Explaining OWASP top 10 for LLMs
    • Demonstrating prompt injection and mitigation
    • Prompt injection detection with Hugginface models
    • Validating answers from LLMs
    • Using Hugginface models to check toxic outputs
    • Prompting LLM for opinions on vulnerabilities

How to Get Started

Follow this structured approach to dive into the repository:

  • Run Using a Devcontainer: The project includes a devcontainer for local execution.
  • Run Locally:
    • Use Microsoft VSCode to run demos.
    • Run Python Jupyter notebooks locally.
    • Utilize Poetry as the virtual environment manager.

Using Poetry

Poetry is a new package manager that simplifies dependency management. Here’s a brief analogy to explain it:

Imagine crafting a finely tuned orchestra. Just as a conductor ensures that every musician plays their part at the right time, Poetry manages your Python packages so they all play together harmoniously. Instead of worrying about each individual instrument (or library), you focus on the beautiful music (your application) being produced.

Here’s how to set up Poetry:

poetry init
poetry install --no-root

Troubleshooting

If you encounter issues while running the repository, consider these troubleshooting tips:

  • Ensure Python 3.11 is installed. Most examples are compatible with 3.12, so consider using it if issues persist.
  • Double-check your VSCode settings for the correct Python interpreter path.
  • If you face issues related to Poetry, reinstall it and ensure your packages are up-to-date.
  • For additional resources or to collaborate on AI development projects, stay connected with fxis.ai.

More Ways to Contribute

We encourage your involvement! Whether it’s suggesting new lesson topics or sharing your experiences, your feedback shapes the future of this repository.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Jump right in and explore the repository! [Learn More Here](https://github.com/jedi4ever/learning-llms-and-genai-for-dev-sec-ops)!

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox