samos123 commited on
Commit
29a3379
·
1 Parent(s): cc3deb8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +42 -0
README.md CHANGED
@@ -19,4 +19,46 @@ Only use the API reference to understand the syntax of the request.
19
 
20
  ## Answer
21
  {output}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  ```
 
19
 
20
  ## Answer
21
  {output}
22
+ ```
23
+
24
+ ## Example usage
25
+ ```python
26
+ from transformers import AutoTokenizer, AutoModelForCausalLM
27
+ import torch
28
+
29
+ model_id = "substratusai/weaviate-gorilla-v4-random-split"
30
+
31
+ model = AutoModelForCausalLM.from_pretrained(
32
+ model_id,
33
+ load_in_4bit=True,
34
+ device_map='auto',
35
+ )
36
+
37
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
38
+
39
+ text = """
40
+ ## Instruction
41
+ Your task is to write GraphQL for the Natural Language Query provided. Use the provided API reference and Schema to generate the GraphQL. The GraphQL should be valid for Weaviate.
42
+
43
+ Only use the API reference to understand the syntax of the request.
44
+
45
+ ## Natural Language Query
46
+ ```text Get me the top 10 historical events related to 'World War II', and show the event name, description, year, significant impact, and the names and populations of the involved countries. ```
47
+
48
+ ## Schema
49
+ { "classes": [ { "class": "HistoricalEvent", "description": "Information about historical events", "vectorIndexType": "hnsw", "vectorizer": "text2vec-transformers", "properties": [ { "name": "eventName", "dataType": ["text"], "description": "Name of the historical event" }, { "name": "description", "dataType": ["text"], "description": "Detailed description of the event" }, { "name": "year", "dataType": ["int"], "description": "Year the event occurred" }, { "name": "hadSignificantImpact", "dataType": ["boolean"], "description": "Whether the event had a significant impact" }, { "name": "involvedCountries", "dataType": ["Country"], "description": "Countries involved in the event" }{ "class": "Country", "description": "Information about countries", "vectorIndexType": "hnsw", "vectorizer": "text2vec-transformers", "properties": [ { "name": "countryName", "dataType": ["text"], "description": "Name of the country" }, { "name": "population", "dataType": ["int"], "description": "Population of the country" }}}
50
+
51
+ ## API reference
52
+ 1. Limit BM25 search results Limit the results[] You can limit the number of results returned by a `bm25` search, - to a fixed number, using the `limit: <N>` operator - to the first N "drops" in `score`, using the `autocut` operator `autocut` can be combined with `limit: N`, which would limit autocut's input to the first `N` objects. Limiting the number of results Use the `limit` argument to specify the maximum number of results that should be returned: ```graphql { Get { JeopardyQuestion( bm25: { query: "safety" }, limit: 3 ) { question answer _additional { score } } } } ```
53
+
54
+ ## Answer
55
+ ```graphql
56
+ """
57
+ device = "cuda:0"
58
+
59
+ inputs = tokenizer(text, return_tensors="pt").to(device)
60
+ # this was needed due to a issue with model not taking token_type_ids
61
+ # inputs.pop("token_type_ids")
62
+ outputs = model.generate(**inputs, max_new_tokens=300)
63
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
64
  ```