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 necessary libraries | |
import os | |
from ibm_watson_machine_learning.foundation_models import Model | |
from ibm_watson_machine_learning.metanames import GenTextParamsMetaNames as GenParams | |
from ibm_watson_machine_learning.foundation_models.utils.enums import ModelTypes, DecodingMethods | |
def get_model(model_type, api_key, project_id, max_tokens, min_tokens, decoding, temperature, top_k, top_p): | |
generate_params = { | |
GenParams.MAX_NEW_TOKENS: max_tokens, | |
GenParams.MIN_NEW_TOKENS: min_tokens, |
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
#!/bin/bash | |
# Ollama Model Export Script | |
# Usage: bash ollama-export.sh vicuna:7b | |
set -e | |
echo "Ollama Model Export Script" | |
echo "" |
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
pip install "notebook<7" | |
### Saving the Notebook to markdown | |
import IPython | |
#from IPython.lib import kernel | |
from ipykernel.kernelbase import Kernel | |
%%javascript | |
var kernel = IPython.notebook.kernel; | |
var thename = window.document.getElementById("notebook_name").innerHTML; | |
var command = "theNotebook = " + "'"+thename+"'"; |
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 | |
import torch | |
import torch.multiprocessing as mp | |
# Distributed training setup | |
def init_distributed(rank, world_size): | |
os.environ["MASTER_ADDR"] = "localhost" | |
os.environ["MASTER_PORT"] = "12345" | |
if rank == 0: | |
print("Initializing distributed process group...") | |
torch.distributed.init_process_group(backend='nccl', world_size=world_size, rank=rank) |
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 datasets import load_dataset | |
import torch | |
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, AutoTokenizer | |
from peft import LoraConfig | |
from trl import SFTTrainer | |
from transformers import TrainingArguments | |
from accelerate import PartialState | |
# Load the dataset | |
dataset_name = "ruslanmv/ai-medical-dataset" |
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 IPython.display import FileLink | |
!tar -czvf lm-evaluation-harness.tar.gz lm-evaluation-harness | |
def create_download_link(filename): | |
return FileLink(filename) | |
download_link = create_download_link("lm-evaluation-harness.tar.gz") | |
display(download_link) |
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 datasets import load_dataset | |
from IPython.display import clear_output | |
import pandas as pd | |
import re | |
from dotenv import load_dotenv | |
import os | |
from ibm_watson_machine_learning.foundation_models.utils.enums import ModelTypes | |
from ibm_watson_machine_learning.metanames import GenTextParamsMetaNames as GenParams | |
from ibm_watson_machine_learning.foundation_models.utils.enums import DecodingMethods | |
from langchain.llms import WatsonxLLM |
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 | |
from PyPDF2 import PdfReader | |
from langchain.text_splitter import RecursiveCharacterTextSplitter | |
import os | |
from langchain_google_genai import GoogleGenerativeAIEmbeddings | |
import google.generativeai as genai | |
from langchain_community.vectorstores import FAISS | |
from langchain_google_genai import ChatGoogleGenerativeAI | |
from langchain.chains.question_answering import load_qa_chain | |
from langchain.prompts import PromptTemplate |
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
# Create a shell script | |
script_content = f''' | |
#!/bin/bash | |
source activate automatic | |
"$@" | |
''' | |
# Write the script to a file | |
script_filename = 'run' | |
with open(script_filename, 'w') as script_file: | |
script_file.write(script_content) |
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 subprocess | |
import sys | |
import venv | |
import os | |
venv.create("venv", with_pip=True) |
NewerOlder