Code Monkey home page Code Monkey logo

research-intern's Introduction

TCS Research Intern

Steps to clone the repo into your local machine

  • Move into your desired directory and open terminal there
  • In the terminal, enter the command : git clone https://github.com/AnikateKoul/Research-Intern.git
  • This will clone the repo into your local device
  • Move into the repo and create a virtual environment using : python -m venv env
  • Install all the dependencies using : pip install -r requirements. txt
  • Also create a file under the name config.json and your Gemini API key and HuggingFace API token under the names apiKey and hugging_face_token respectively.
  • Finally, install the Toxic Language Check and Competitors Check validators using the following commands :
    • guardrails hub install hub://guardrails/toxic_language and
    • guardrails hub install hub://guardrails/competitor_check respectively

Below is the basic explanation for the various files in this repo :

base_prompt.ipynb

In this file, we try to create a simple LLM wrapper using Gemini API without using any guardrails.

guardrails_ai_wrapper.ipynb

In this file, we use the Guardrails AI framework to construct a guardrail that checks for toxic language and mentions of given competitors in the given text. We then use this guardrail to validate both the user prompt and also the output generated by the LLM.

In this case also, the LLM used is the Gemini 1.5 Flash latest.

guardrails_with_hugging_face.ipynb

In this file, we use Guardrails AI to create guardrails for image based models, which in this case is the Stability AI Stable diffusion XL model. Similar to the preceding file, we check for toxic language and mentions of given competitors, but in this case, in only the input text.

The hosted API for the image generation model is provided by Hugging Face.

jail_break_prevention.ipynb

In this file, we use 2 LLMs. One is the previously used Gemini 1.5 Flash latest. This is used as a guardrail in this example. The second LLM used is the Mistral 7B Instruct v0.2 which is used as the main LLM for generating response for the user input.

The Gemini model is set to answer in only YES or NO depending on the input. This output is then used to decide whether a query is to be answered by the main LLM or not.

guardrails_ai_with_reask.ipynb

In this file, we use the RAIL spec facility provided by Guardrails AI. Using this facility, we can create a .xml file and list down our requirements there. This file will be then used to generate the output in correct format and satisfying all the mentioned conditions.

It also has the option to trigger a reask, if any part of the output generated does not satisfy a given condition. In our example, we use it generate fake json datasets.

research-intern's People

Contributors

anikatekoul avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.