Views
No views yet

Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
{prompt}
### Response:
desc_act. True results in better quantisation accuracy. Some GPTQ clients have had issues with models that use Act Order plus Group Size, but this is generally resolved now.| Branch | Bits | GS | Act Order | Damp % | GPTQ Dataset | Seq Len | Size | ExLlama | Desc |
|---|---|---|---|---|---|---|---|---|---|
| main | 4 | None | Yes | 0.1 | VMware Open Instruct | 8192 | 23.81 GB | No | 4-bit, with Act Order. No group size, to lower VRAM requirements. |
| gptq-4bit-128g-actorder_True | 4 | 128 | Yes | 0.1 | VMware Open Instruct | 8192 | 24.70 GB | No | 4-bit, with Act Order and group size 128g. Uses even less VRAM than 64g, but with slightly lower accuracy. |
| gptq-4bit-32g-actorder_True | 4 | 32 | Yes | 0.1 | VMware Open Instruct | 8192 | 27.42 GB | No | 4-bit, with Act Order and group size 32g. Gives highest possible inference quality, with maximum VRAM usage. |
| gptq-3bit--1g-actorder_True | 3 | None | Yes | 0.1 | VMware Open Instruct | 8192 | 18.01 GB | No | 3-bit, with Act Order and no group size. Lowest possible VRAM requirements. May be lower quality than 3-bit 128g. |
| gptq-3bit-128g-actorder_True | 3 | 128 | Yes | 0.1 | VMware Open Instruct | 8192 | 18.85 GB | No | 3-bit, with group size 128g and act-order. Higher quality than 128g-False. |
| gptq-8bit--1g-actorder_True | 8 | None | Yes | 0.1 | VMware Open Instruct | 8192 | 47.04 GB | No | 8-bit, with Act Order. No group size, to lower VRAM requirements. |
| gptq-8bit-128g-actorder_True | 8 | 128 | Yes | 0.1 | VMware Open Instruct | 8192 | 48.10 GB | No | 8-bit, with group size 128g for higher inference quality and with Act Order for even higher accuracy. |
main branch, enter TheBloke/bagel-8x7b-v0.2-GPTQ in the "Download model" box.:branchname to the end of the download name, eg TheBloke/bagel-8x7b-v0.2-GPTQ:gptq-4bit-128g-actorder_Truehuggingface-hub Python library:pip3 install huggingface-hubmain branch to a folder called bagel-8x7b-v0.2-GPTQ:1mkdir bagel-8x7b-v0.2-GPTQ
2huggingface-cli download TheBloke/bagel-8x7b-v0.2-GPTQ --local-dir bagel-8x7b-v0.2-GPTQ --local-dir-use-symlinks False--revision parameter:1mkdir bagel-8x7b-v0.2-GPTQ
2huggingface-cli download TheBloke/bagel-8x7b-v0.2-GPTQ --revision gptq-4bit-128g-actorder_True --local-dir bagel-8x7b-v0.2-GPTQ --local-dir-use-symlinks False--local-dir-use-symlinks False parameter, the files will instead be stored in the central Hugging Face cache directory (default location on Linux is: ~/.cache/huggingface), and symlinks will be added to the specified --local-dir, pointing to their real location in the cache. This allows for interrupted downloads to be resumed, and allows you to quickly clone the repo to multiple places on disk without triggering a download again. The downside, and the reason why I don't list that as the default option, is that the files are then hidden away in a cache folder and it's harder to know where your disk space is being used, and to clear it up if/when you want to remove a download model.HF_HOME environment variable, and/or the --cache-dir parameter to huggingface-cli.huggingface-cli, please see: HF -> Hub Python Library -> Download files -> Download from the CLI.hf_transfer:pip3 install hf_transferHF_HUB_ENABLE_HF_TRANSFER to 1:1mkdir bagel-8x7b-v0.2-GPTQ
2HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/bagel-8x7b-v0.2-GPTQ --local-dir bagel-8x7b-v0.2-GPTQ --local-dir-use-symlinks Falseset HF_HUB_ENABLE_HF_TRANSFER=1 before the download command.git (not recommended)git, use a command like this:git clone --single-branch --branch gptq-4bit-128g-actorder_True https://huggingface.co/TheBloke/bagel-8x7b-v0.2-GPTQhuggingface-hub, and will use twice as much disk space as it has to store the model files twice (it stores every byte both in the intended target folder, and again in the .git folder as a blob.)TheBloke/bagel-8x7b-v0.2-GPTQ.TheBloke/bagel-8x7b-v0.2-GPTQ:gptq-4bit-128g-actorder_Truebagel-8x7b-v0.2-GPTQquantize_config.json.ghcr.io/huggingface/text-generation-inference:1.1.0--model-id TheBloke/bagel-8x7b-v0.2-GPTQ --port 3000 --quantize gptq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096pip3 install huggingface-hub1from huggingface_hub import InferenceClient
2
3endpoint_url = "https://your-endpoint-url-here"
4
5prompt = "Tell me about AI"
6prompt_template=f'''Below is an instruction that describes a task. Write a response that appropriately completes the request.
7
8### Instruction:
9{prompt}
10
11### Response:
12'''
13
14client = InferenceClient(endpoint_url)
15response = client.text_generation(
16 prompt_template,
17 max_new_tokens=128,
18 do_sample=True,
19 temperature=0.7,
20 top_p=0.95,
21 top_k=40,
22 repetition_penalty=1.1
23)
24
25print(f"Model output: {response}")1pip3 install --upgrade transformers optimum
2# If using PyTorch 2.1 + CUDA 12.x:
3pip3 install --upgrade auto-gptq
4# or, if using PyTorch 2.1 + CUDA 11.x:
5pip3 install --upgrade auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/1pip3 uninstall -y auto-gptq
2git clone https://github.com/PanQiWei/AutoGPTQ
3cd AutoGPTQ
4git checkout v0.5.1
5pip3 install .1from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
2
3model_name_or_path = "TheBloke/bagel-8x7b-v0.2-GPTQ"
4# To use a different branch, change revision
5# For example: revision="gptq-4bit-128g-actorder_True"
6model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
7 device_map="auto",
8 trust_remote_code=False,
9 revision="main")
10
11tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
12
13prompt = "Write a story about llamas"
14system_message = "You are a story writing assistant"
15prompt_template=f'''Below is an instruction that describes a task. Write a response that appropriately completes the request.
16
17### Instruction:
18{prompt}
19
20### Response:
21'''
22
23print("\n\n*** Generate:")
24
25input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
26output = model.generate(inputs=input_ids, temperature=0.7, do_sample=True, top_p=0.95, top_k=40, max_new_tokens=512)
27print(tokenizer.decode(output[0]))
28
29# Inference can also be done using transformers' pipeline
30
31print("*** Pipeline:")
32pipe = pipeline(
33 "text-generation",
34 model=model,
35 tokenizer=tokenizer,
36 max_new_tokens=512,
37 do_sample=True,
38 temperature=0.7,
39 top_p=0.95,
40 top_k=40,
41 repetition_penalty=1.1
42)
43
44print(pipe(prompt_template)[0]['generated_text'])
conda activate text-generation-inferencecd Desktop/text-generation-inference/volume=$PWD/datamodel=jondurbin/bagel-8x7b-v0.2sudo docker run --gpus '"device=0,1,2,3"' --shm-size 1g -p 8080:80 -v $volume:/data ghcr.io/huggingface/text-generation-inference:1.3 --model-id $modelcurl 0.0.0.0:8080/generate \
-X POST \
-d '{"inputs":"<|system|>You are a friendly chatbot.\n<|user|>What type of model are you?\n<|assistant|>","parameters":{"do_sample": true, "max_new_tokens": 100, "repetition_penalty": 1.15, "temperature": 0.7, "top_k": 20, "top_p": 0.9, "best_of": 1}}'\
-H 'Content-Type: application/json'curl IP_ADDRESS_PROVIDED_BY_MASSED_COMPUTE_VM:8080/generate \
-X POST \
-d '{"inputs":"<|system|>You are a friendly chatbot.\n<|user|>What type of model are you?\n<|assistant|>","parameters":{"do_sample": true, "max_new_tokens": 100, "repetition_penalty": 1.15, "temperature": 0.7, "top_k": 20, "top_p": 0.9, "best_of": 1}}'\
-H 'Content-Type: application/jsonBelow is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
{system prompt, if provided}
{instruction}
### Response:### Input: block, so the inputs are just in the instruction section.{system prompt, if provided, randomly defaulting to "A chat between a user and an unbiased, uncensored assistant."}
USER: {instruction}
ASSISTANT: <|im_start|> and <|im_end|>, because in practice they just act as BOS and EOS tokens (but, please correct me if I'm wrong).1{bos}<|im_start|>{role}
2{text}
3<|im_end|>{eos}1{bos}{role}
2{text}
3{eos}<|im_start|> and <|im_end|>, just update your tokenizer_config.json to use <|im_start|> instead of <s> and <|im_end|> instead of </s> and when tokenizing. And if you still don't like what I've done to this chat-ml-ish format, feel free to cry into your pillow or fork the code and do a new fine-tune.[INST] <<SYS>>
{system}
<</SYS>>
{instruction} [/INST]tokenizer_config.json includes the default chat template (llama-2), so you can simply use the apply_chat_template method to build the full prompt.import transformers
tokenizer = transformers.AutoTokenizer.from_pretrained('jondurbin/bagel-8x7b-v0.2')
chat = [
{"role": "system", "content": "You are Bob, a friendly AI assistant."},
{"role": "user", "content": "Hello, how are you?"},
{"role": "assistant", "content": "I'm doing great. How can I help you today?"},
{"role": "user", "content": "I'd like to show off how chat templating works!"},
]
print(tokenizer.apply_chat_template(chat, tokenize=False))BEGININPUT
BEGINCONTEXT
[key0: value0]
[key1: value1]
... other metdata ...
ENDCONTEXT
[insert your text blocks here]
ENDINPUT
[add as many other blocks, in the exact same format]
BEGININSTRUCTION
[insert your instruction(s). The model was tuned with single questions, paragraph format, lists, etc.]
ENDINSTRUCTIONBEGININPUT - denotes a new input blockBEGINCONTEXT - denotes the block of context (metadata key/value pairs) to associate with the current input blockENDCONTEXT - denotes the end of the metadata block for the current inputENDINPUT - denotes the end of the current input blockBEGININSTRUCTION - denotes the start of the list (or one) instruction(s) to respond to for all of the input blocks above.ENDINSTRUCTION - denotes the end of instruction setBEGININPUT
BEGINCONTEXT
date: 2021-01-01
url: https://web.site/123
ENDCONTEXT
In a shocking turn of events, blueberries are now green, but will be sticking with the same name.
ENDINPUT
BEGININSTRUCTION
What color are bluberries? Source?
ENDINSTRUCTIONBlueberries are now green.
Source:
date: 2021-01-01
url: https://web.site/123BEGININPUT
{text to summarize}
ENDINPUT
BEGININSTRUCTION
Summarize the input in around 130 words.
ENDINSTRUCTIONAs an AI assistant, please select the most suitable function and parameters from the list of available functions below, based on the user's input. Provide your response in JSON format.
Input: I want to know how many times 'Python' is mentioned in my text file.
Available functions:
file_analytics:
description: This tool performs various operations on a text file.
params:
action: The operation we want to perform on the data, such as "count_occurrences", "find_line", etc.
filters:
keyword: The word or phrase we want to search for.1{
2 "function": "file_analytics",
3 "params": {
4 "action": "count_occurrences",
5 "filters": {
6 "keyword": "Python"
7 }
8 }
9}Please construct a systematic plan to generate an optimal response to the user instruction, utilizing a set of provided tools. Each plan will correspond to an evidence value, which will be the output of one of the available functions given an input string
that could be the user's question, one or more prior evidence values, or a combination of both.
Here are the tools available to be called:
DuckDuckGo[input]: Tool that enables the user to search for information using the DuckDuckGo search engine. This tool is helpful in locating a suitable list of sites that may contain the answer to the user's query. It does not directly answer the question but finds a list of sites that might have the answer.
TextScraper[input]: Load one or more websites from the input string containing newline delimited links, where input is one or more links, and produces plain text output containing the content of the links.
HyperlinkExtractor[input]: Extract links from plain text and produces a plain text, newline delimited response of links.
KnowledgeModel[input]: Question answering language model, particularly useful in answering questions based on an input passage of text. The input must be a text question that references an :evidence[n]: variable, e.g. What color is the cat, given :evidence1:?
The output should be in format:
Plan: [first action to take based on input question]
:evidence0: = [function to call with input parameter]
Plan: [next action to take, based on result of :evidence0:]
:evidence1: = [next function to call and input parameter, which may include reference to previous evidence, e.g. "Given context :evidence0"]
...
Answer: [:evidence[n]: containing the final answer.]
Question: Who won the Nobel Prize in Literature in 2020 and what is their most famous work?Plan: Begin by conducting a web search to find out who won the Nobel Prize in Literature in 2020.
:evidence0: = DuckDuckGo[Nobel Prize in Literature 2020 winner]
Plan: Utilize the KnowledgeModel to interpret the search results and find the name of the laureate.
:evidence1: = KnowledgeModel[Who won the Nobel Prize in Literature in 2020, given :evidence0:?]
Plan: Conduct another web search to find the most famous work of the identified laureate.
:evidence2: = DuckDuckGo[Most famous work of :evidence1:]
Plan: Extract the relevant links from the DuckDuckGo search results for a more focused search.
:evidence3: = HyperlinkExtractor[:evidence2:]
Plan: Use the TextScraper tool to extract information from the relevant links.
:evidence4: = TextScraper[:evidence3:]
Plan: Finally, utilize the KnowledgeModel to identify and summarize the most famous work of the laureate from the extracted information.
:evidence5: = KnowledgeModel[What is the most famous work of :evidence1:, given :evidence4:?]
Answer: :evidence5:1import re
2import requests
3
4def inject_context(input_text, **context):
5 for ref in set(re.findall(r"(:evidence[0-9]+:)", input_text, re.I)):
6 input_text = input_text.replace(ref, context.get(ref, ""))
7 return input_text
8
9def duckduckgo(input_text, **context):
10 search_string = inject_context(input_text, **context)
11 ... search via duck duck go using search_string
12 ... return text content
13
14def link_extractor(input_text, **context):
15 input_text = inject_context(input_text, **context)
16 return "\n".join(list(set(re.findall(r"(https?://[^\s]+?\.?)", input_text, re.I))))
17
18def scrape(input_text, **context):
19 input_text = inject_context(input_text, **context)
20 text = []
21 for link in input_text.splitlines():
22 text.append(requests.get(link).text)
23 return "\n".join(text)
24
25def infer(input_text, **context)
26 prompt = inject_context(input_text, **context)
27 ... call model with prompt, return output
28
29def parse_plan(plan):
30 method_map = {
31 "DuckDuckGo": duckduckgo,
32 "HyperlinkExtractor": link_extractor,
33 "KnowledgeModel": infer,
34 "TextScraper": scrape,
35 }
36 context = {}
37 for line in plan.strip().splitlines():
38 if line.startswith("Plan:"):
39 print(line)
40 continue
41 parts = re.match("^(:evidence[0-9]+:)\s*=\s*([^\[]+])(\[.*\])\s$", line, re.I)
42 if not parts:
43 if line.startswith("Answer: "):
44 return context.get(line.split(" ")[-1].strip(), "Answer couldn't be generated...")
45 raise RuntimeError("bad format: " + line)
46 context[parts.group(1)] = method_map[parts.group(2)](parts.group(3), **context)