Instructions to use avinashm/text2cypher with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use avinashm/text2cypher with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf avinashm/text2cypher # Run inference directly in the terminal: llama cli -hf avinashm/text2cypher
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf avinashm/text2cypher # Run inference directly in the terminal: llama cli -hf avinashm/text2cypher
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf avinashm/text2cypher # Run inference directly in the terminal: ./llama-cli -hf avinashm/text2cypher
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf avinashm/text2cypher # Run inference directly in the terminal: ./build/bin/llama-cli -hf avinashm/text2cypher
Use Docker
docker model run hf.co/avinashm/text2cypher
- LM Studio
- Jan
- Ollama
How to use avinashm/text2cypher with Ollama:
ollama run hf.co/avinashm/text2cypher
- Unsloth Studio
How to use avinashm/text2cypher with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for avinashm/text2cypher to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for avinashm/text2cypher to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for avinashm/text2cypher to start chatting
- Docker Model Runner
How to use avinashm/text2cypher with Docker Model Runner:
docker model run hf.co/avinashm/text2cypher
- Lemonade
How to use avinashm/text2cypher with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull avinashm/text2cypher
Run and chat with the model
lemonade run user.text2cypher-{{QUANT_TAG}}List all available models
lemonade list
- Atomic Chat
Update README.md
Browse files
README.md
CHANGED
|
@@ -21,6 +21,67 @@ Dataset: neo4j/text2cypher-2024v1
|
|
| 21 |
|
| 22 |
An overview of the finetuned models and benchmarking results are shared at https://medium.com/p/d77be96ab65a and https://medium.com/p/b2203d1173b0
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
## Bias, Risks, and Limitations
|
| 26 |
|
|
|
|
| 21 |
|
| 22 |
An overview of the finetuned models and benchmarking results are shared at https://medium.com/p/d77be96ab65a and https://medium.com/p/b2203d1173b0
|
| 23 |
|
| 24 |
+
## Example Cypher generation
|
| 25 |
+
`python
|
| 26 |
+
import openai
|
| 27 |
+
|
| 28 |
+
# Define the instruction and helper functions
|
| 29 |
+
instruction = (
|
| 30 |
+
"Generate Cypher statement to query a graph database. "
|
| 31 |
+
"Use only the provided relationship types and properties in the schema. \n"
|
| 32 |
+
"Schema: {schema} \n Question: {question} \n Cypher output: "
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
def prepare_chat_prompt(question, schema):
|
| 36 |
+
# Build the messages list for the OpenAI API
|
| 37 |
+
return [
|
| 38 |
+
{
|
| 39 |
+
"role": "user",
|
| 40 |
+
"content": instruction.format(schema=schema, question=question),
|
| 41 |
+
}
|
| 42 |
+
]
|
| 43 |
+
|
| 44 |
+
def _postprocess_output_cypher(output_cypher: str) -> str:
|
| 45 |
+
# Remove any explanation text and code block markers
|
| 46 |
+
partition_by = "**Explanation:**"
|
| 47 |
+
output_cypher, _, _ = output_cypher.partition(partition_by)
|
| 48 |
+
output_cypher = output_cypher.strip("`\n")
|
| 49 |
+
output_cypher = output_cypher.lstrip("cypher\n")
|
| 50 |
+
output_cypher = output_cypher.strip("`\n ")
|
| 51 |
+
return output_cypher
|
| 52 |
+
|
| 53 |
+
# Configure the OpenAI API endpoint to your Ollama server.
|
| 54 |
+
# (Adjust the API base URL if your Ollama server is hosted at a different address/port.)
|
| 55 |
+
openai.api_base = "http://localhost:11434/v1"
|
| 56 |
+
openai.api_key = "YOUR_API_KEY" # Include if your setup requires an API key
|
| 57 |
+
|
| 58 |
+
# Set the model name as used by Ollama (this should match the name configured on your Ollama server)
|
| 59 |
+
model_name = "avinashm/text2cypher"
|
| 60 |
+
|
| 61 |
+
# Define the question and schema
|
| 62 |
+
question = "What are the movies of Tom Hanks?"
|
| 63 |
+
schema = "(:Actor)-[:ActedIn]->(:Movie)"
|
| 64 |
+
|
| 65 |
+
# Prepare the conversation messages
|
| 66 |
+
messages = prepare_chat_prompt(question=question, schema=schema)
|
| 67 |
+
|
| 68 |
+
# Call the API using similar generation parameters to your original script.
|
| 69 |
+
response = openai.ChatCompletion.create(
|
| 70 |
+
model=model_name,
|
| 71 |
+
messages=messages,
|
| 72 |
+
temperature=0.2,
|
| 73 |
+
max_tokens=512, # equivalent to max_new_tokens in your original script
|
| 74 |
+
top_p=0.9,
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
# Extract and post-process the output
|
| 78 |
+
raw_output = response["choices"][0]["message"]["content"]
|
| 79 |
+
output = _postprocess_output_cypher(raw_output)
|
| 80 |
+
|
| 81 |
+
print(output)
|
| 82 |
+
`
|
| 83 |
+
|
| 84 |
+
|
| 85 |
|
| 86 |
## Bias, Risks, and Limitations
|
| 87 |
|