File size: 791 Bytes
4997aeb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import streamlit as st
import os
from streamlit_chat import message


from datasets import load_dataset

dataset = load_dataset("wikipedia", "20220301.en", split="train[240000:290000]")


wikidata = []

for record in dataset:
    wikidata.append(record["text"])

wikidata = list(set(wikidata))
# print("\n".join(wikidata[:5]))
# print(len(wikidata))

from sentence_transformers import SentenceTransformer
import torch

device = 'cuda' if torch.cuda.is_available() else 'cpu'

if device != 'cuda':
    print(f"you are using {device}. This is much slower than using "
    "a CUDA-enabled GPU. If on colab you can chnage this by "
    "clicking Runtime > change runtime type > GPU.")

model = SentenceTransformer("all-MiniLM-L6-v2", device=device)

# Creating a Index(Pinecone Vector Database)