This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from langchain.docstore.document import Document | |
from langchain.text_splitter import RecursiveCharacterTextSplitter | |
from langchain.embeddings.openai import OpenAIEmbeddings | |
from langchain.vectorstores import Qdrant | |
from qdrant_client import QdrantClient | |
# --- Step 1: Extract text from the document --- | |
def extract_text(file_path: str) -> str: | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ./Llama-3-ELYZA-JP-8B-q4_k_m.gguf | |
TEMPLATE """{{ if .System }}<|start_header_id|>system<|end_header_id|> | |
{{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|> | |
{{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|> | |
{{ .Response }}<|eot_id|>""" | |
PARAMETER stop "<|start_header_id|>" | |
PARAMETER stop "<|end_header_id|>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import FastAPI, HTTPException | |
from pydantic import BaseModel | |
from openai import OpenAI | |
from dotenv import load_dotenv | |
import os | |
load_dotenv() | |
app = FastAPI() | |
client = OpenAI() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
# Base endpoint | |
base_url = "https://r.jina.ai/" | |
# Input URL to be appended | |
input_url = "https://www.stateof.ai/" | |
# Full URL with the input URL appended after a plus (+) sign | |
full_url = base_url + input_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
# App title | |
st.title('EcoOptimizer Carbon Footprint Calculator') | |
# Introduction | |
st.write(''' | |
This tool calculates the Software Carbon Intensity (SCI) for EcoOptimizer, | |
an AI-powered energy management system for commercial buildings by EcoTech Solutions. | |
''') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
training_arguments = TrainingArguments( | |
output_dir="./results", | |
per_device_train_batch_size=4, | |
per_device_eval_batch_size=4, | |
gradient_accumulation_steps=2, | |
optim="adamw_8bit", | |
logging_steps=50, | |
learning_rate=1e-4, | |
evaluation_strategy="steps", | |
do_eval=True, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## With Evaluation Harness | |
!pip install git+https://github.com/EleutherAI/lm-evaluation-harness.git | |
!pip install bitsandbytes | |
!pip install --upgrade transformers | |
!pip install auto-gptq optimum autoawq | |
!lm_eval --model hf --model_args pretrained=google/gemma-7b --tasks winogrande,hellaswag,arc_challenge --device cuda:0 --num_fewshot 1 --batch_size 8 --output_path ./eval_harness/gemma-7b | |
!lm_eval --model hf --model_args pretrained=google/gemma-7b --tasks winogrande,hellaswag,arc_challenge --device cuda:0 --num_fewshot 5 --batch_size 8 --output_path ./eval_harness/gemma-7b-5shot | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
#set you runpod key as a environment variable | |
os.environ['RUNPOD_API_KEY'] = "your_runpod_api_key" | |
import runpod | |
from IPython.display import display, Markdown | |
runpod.api_key = os.getenv("RUNPOD_API_KEY", "your_runpod_api_key") | |
if runpod.api_key == "your_runpod_api_key": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello everyone, I am Sneha Roy, working as a full-stack AI Engineer and recently I have been working on Generative AI projects. | |
Today, I will be showcasing a solution that we have developed.........."GCC KB Chatbot". | |
it is an intelligent assistant tailored to simplify how call centers operate, in this case.. the GCC team. | |
GCC faces a significant challenge managing a high volume of tickets daily. | |
Each of these tickets is needing assistance, and each minute spent resolving one is critical. | |
Traditionally, our colleagues at GCC relied on a comprehensive but cumbersome Knowledge Base (KB) to find solutions, | |
which significantly contributed to longer turnaround times. | |
That's where our solution comes in... it drastically reduces the time taken to resolve tickets. Acting as a virtual agent, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from transformers import BertTokenizer, BertModel | |
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased') | |
model = BertModel.from_pretrained('bert-base-uncased') | |
def encode(text): | |
tokens = tokenizer.tokenize(text) | |
tokens = ['[CLS]'] + tokens + ['[SEP]'] | |
return tokenizer.convert_tokens_to_ids(tokens) |
NewerOlder