GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — REST/datastore/get_datastore_code.py at main · FasterDecoding/REST

Expand file tree

/

get_datastore_code.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
54 lines (45 loc) · 1.56 KB
/

get_datastore_code.py

Copy path

File metadata and controls

54 lines (45 loc) · 1.56 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from datasets import load_dataset
from transformers import AutoTokenizer
import draftretriever
from tqdm import tqdm
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"--model-path",
type=str,
default="codellama/CodeLlama-7b-instruct-hf",
help="The path to the weights. This can be a local folder or a Hugging Face repo ID.",
)
parser.add_argument(
"--large-datastore",
type=bool,
default=False,
help="Whether to use a large datastore",
)
args = parser.parse_args()
print(args)
tokenizer = AutoTokenizer.from_pretrained(args.model_path)
segment = 30 if args.large_datastore else 1 # Maximum number of segment: 144
data_files = []
for i in range(segment):
if i>=100:
data_files.append(f"data-00{i}-of-00144.parquet")
elif i >=10:
data_files.append(f"data-000{i}-of-00144.parquet")
else:
data_files.append(f"data-0000{i}-of-00144.parquet")
print("data_files:", data_files)
dataset = load_dataset('bigcode/the-stack-dedup', \
data_dir='data/python', split='train', data_files=data_files)
datastore_path = './datastore_stack_large.idx' if args.large_datastore else './datastore_stack_small.idx'
writer = draftretriever.Writer(
index_file_path=datastore_path,
max_chunk_len=512 * 1024 * 1024,
vocab_size=tokenizer.vocab_size + len(tokenizer.get_added_vocab()),
)
total_length = len(dataset)
print("number of samples: ", total_length)
for sample in tqdm(dataset, total=len(dataset)):
token_list = tokenizer.encode(sample['content'])
writer.add_entry(token_list)
writer.finalize()
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.