Update README.md
Browse files
README.md
CHANGED
@@ -1 +1,42 @@
|
|
1 |
-
This model is a merged version of [parlance-labs/hc-mistral-alpaca](https://huggingface.co/parlance-labs/hc-mistral-alpaca)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
This model is a merged version of [parlance-labs/hc-mistral-alpaca](https://huggingface.co/parlance-labs/hc-mistral-alpaca)
|
2 |
+
|
3 |
+
## Usage
|
4 |
+
|
5 |
+
```python
|
6 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
7 |
+
model_id='parlance-labs/hc-mistral-alpaca-merged'
|
8 |
+
model = AutoModelForCausalLM.from_pretrained(model_id).cuda()
|
9 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
10 |
+
tokenizer.pad_token = tokenizer.eos_token
|
11 |
+
```
|
12 |
+
|
13 |
+
```python
|
14 |
+
def prompt(nlq, cols):
|
15 |
+
return f"""Honeycomb is an observability platform that allows you to write queries to inspect trace data. You are an assistant that takes a natural language query (NLQ) and a list of valid columns and produce a Honeycomb query.
|
16 |
+
|
17 |
+
### Instruction:
|
18 |
+
|
19 |
+
NLQ: "{nlq}"
|
20 |
+
|
21 |
+
Columns: {cols}
|
22 |
+
|
23 |
+
### Response:
|
24 |
+
"""
|
25 |
+
|
26 |
+
def prompt_tok(nlq, cols):
|
27 |
+
_p = prompt(nlq, cols)
|
28 |
+
input_ids = tokenizer(_p, return_tensors="pt", truncation=True).input_ids.cuda()
|
29 |
+
out_ids = model.generate(input_ids=input_ids, max_new_tokens=5000,
|
30 |
+
do_sample=False)
|
31 |
+
return tokenizer.batch_decode(out_ids.detach().cpu().numpy(),
|
32 |
+
skip_special_tokens=True)[0][len(_p):]
|
33 |
+
```
|
34 |
+
|
35 |
+
```python
|
36 |
+
nlq = "Exception count by exception and caller"
|
37 |
+
cols = ['error', 'exception.message', 'exception.type', 'exception.stacktrace', 'SampleRate', 'name', 'db.user', 'type', 'duration_ms', 'db.name', 'service.name', 'http.method', 'db.system', 'status_code', 'db.operation', 'library.name', 'process.pid', 'net.transport', 'messaging.system', 'rpc.system', 'http.target', 'db.statement', 'library.version', 'status_message', 'parent_name', 'aws.region', 'process.command', 'rpc.method', 'span.kind', 'serializer.name', 'net.peer.name', 'rpc.service', 'http.scheme', 'process.runtime.name', 'serializer.format', 'serializer.renderer', 'net.peer.port', 'process.runtime.version', 'http.status_code', 'telemetry.sdk.language', 'trace.parent_id', 'process.runtime.description', 'span.num_events', 'messaging.destination', 'net.peer.ip', 'trace.trace_id', 'telemetry.instrumentation_library', 'trace.span_id', 'span.num_links', 'meta.signal_type', 'http.route']
|
38 |
+
|
39 |
+
# print prediction
|
40 |
+
out = prompt_tok(nlq, cols)
|
41 |
+
print(nlq, '\n', out)
|
42 |
+
```
|