Dhruv commited on
Commit
9e8bd13
1 Parent(s): c44d252

WIP: adding functions for loading and tokenization

Browse files
Files changed (2) hide show
  1. LLM_middleware.py +15 -1
  2. README.md +18 -0
LLM_middleware.py CHANGED
@@ -5,10 +5,24 @@ from typing import List, Optional
5
 
6
  import openai
7
  from transformers import AutoTokenizer, AutoModelForCausalLM
8
-
9
 
10
  class LLM_Middleware():
11
  hf_key: str
 
 
12
  def __init__(self, openai_key, hf) -> None:
13
  openai.key = openai_key
14
  self.hf_key = hf
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  import openai
7
  from transformers import AutoTokenizer, AutoModelForCausalLM
8
+ from datasets import load_datasets
9
 
10
  class LLM_Middleware():
11
  hf_key: str
12
+ dataset
13
+
14
  def __init__(self, openai_key, hf) -> None:
15
  openai.key = openai_key
16
  self.hf_key = hf
17
+ '''
18
+ function for loading the dataset using hf trainer.
19
+ '''
20
+ def loadDataset(self,datasetName: str):
21
+ self.dataset = load_datasets(datasetName)
22
+ return self.dataset
23
+
24
+
25
+ def TokenizerFunction(modelName: str, dataset):
26
+ tokenizer = AutoTokenizer.from_pretrained(modelName)
27
+ ## as its the JSON function, we need to specify other function in order to be specific.
28
+ tokenizer(dataset["text"], padding="max_length", truncation=True)
README.md CHANGED
@@ -15,3 +15,21 @@ tags: ["python", "transformers", "devops", "bioinformatics", ]
15
  ## BioML hackathon submission: building search engine for ressurecting archieved / old packages 🪦
16
 
17
  This repo will integrate the current promonent packages being deployed as transformers to develop the builds for the software and resolve any issues in the current package.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  ## BioML hackathon submission: building search engine for ressurecting archieved / old packages 🪦
16
 
17
  This repo will integrate the current promonent packages being deployed as transformers to develop the builds for the software and resolve any issues in the current package.
18
+
19
+
20
+
21
+ ## How to use
22
+
23
+ - **Install dependencies:**
24
+
25
+ ```bash
26
+ pip install -r requirements.txt
27
+ ```
28
+
29
+ - **Run the app:**
30
+
31
+ ```bash
32
+ gradio app.py
33
+ ```
34
+
35
+ Also you can do the settings in order to setup on hf spaces.