### Run GLM-4.7-Flash-Claude-Opus with llama.cpp Source: https://context7.com/teichai/glm-4.7-flash-claude-opus-4.5-high-reasoning-distill-gguf/llms.txt Guide to running the GLM-4.7-Flash-Claude-4.5-Opus model directly using llama.cpp. It provides examples for general use, tool-calling/coding tasks, and setting up a local server. ```bash # Download a quantized model file # Available: q3_k_m, q3_k_s, q4_k_m, q5_k_m, q6_k, q8_0, iq2_m, iq3_m, iq3_xs, iq4_nl, iq4_xs, bf16, f16 # Run with recommended parameters for general use ./llama-cli -m glm-4.7-flash-claude-4.5-opus.q4_k_m.gguf \ --temp 1.0 \ --top-p 0.95 \ --min-p 0.01 \ --repeat-penalty 1.0 \ -p "Explain quantum entanglement in simple terms" # Run with parameters optimized for tool-calling/coding tasks ./llama-cli -m glm-4.7-flash-claude-4.5-opus.q4_k_m.gguf \ --temp 0.7 \ --top-p 1.0 \ --min-p 0.01 \ -p "Write a Python class for a binary search tree" # Run as a server ./llama-server -m glm-4.7-flash-claude-4.5-opus.q4_k_m.gguf \ --host 0.0.0.0 \ --port 8080 ``` -------------------------------- ### llama.cpp - Server Mode Source: https://context7.com/teichai/glm-4.7-flash-claude-opus-4.5-high-reasoning-distill-gguf/llms.txt Starts a local HTTP server using llama.cpp to serve the model, allowing API-based interaction. ```APIDOC ## llama-server ### Description Starts a local HTTP server using llama.cpp to serve the model, enabling API-based interaction. ### Method CLI Command ### Endpoint N/A (Local server) ### Parameters #### Path Parameters - **-m** (string) - Required - Path to the GGUF model file (e.g., `glm-4.7-flash-claude-4.5-opus.q4_k_m.gguf`). #### Query Parameters - **--host** (string) - Optional - The host address to bind the server to. Defaults to `0.0.0.0`. - **--port** (integer) - Optional - The port number for the server. Defaults to `8080`. ### Request Example ```bash ./llama-server -m glm-4.7-flash-claude-4.5-opus.q4_k_m.gguf \ --host 0.0.0.0 \ --port 8080 ``` ### Response Server starts and listens for incoming HTTP requests on the specified host and port. Output is typically server status messages. ``` -------------------------------- ### GLM-4.7 Chat Template Format and Python Example Source: https://context7.com/teichai/glm-4.7-flash-claude-opus-4.5-high-reasoning-distill-gguf/llms.txt Demonstrates the specific chat template format required for multi-turn conversations with the GLM-4.7 model. Includes a Python function to correctly format prompts for the model. ```text [gMASK]<|system|> You are a helpful assistant specialized in programming.<|user|> How do I reverse a linked list in Python?<|assistant|> Here is how to reverse a linked list... ``` ```python # Python example for formatting prompts def format_glm_prompt(system: str, user: str) -> str: return f"[gMASK]<|system|> {system}<|user|> {user}<|assistant|> " prompt = format_glm_prompt( system="You are an expert programmer.", user="Write a function to check if a number is prime." ) print(prompt) ``` -------------------------------- ### Download Quantized GLM-4.7 Model using Hugging Face CLI Source: https://context7.com/teichai/glm-4.7-flash-claude-opus-4.5-high-reasoning-distill-gguf/llms.txt Shows how to download a specific quantization of the GLM-4.7-Flash-Claude-Opus model from Hugging Face using the command-line interface. This allows users to select the desired balance between model size and quality. ```bash # Download specific quantization from HuggingFace huggingface-cli download TeichAI/GLM-4.7-Flash-Claude-Opus-4.5-High-Reasoning-Distill-GGUF \ glm-4.7-flash-claude-4.5-opus.q4_k_m.gguf \ --local-dir ./models ``` -------------------------------- ### llama.cpp - CLI Usage Source: https://context7.com/teichai/glm-4.7-flash-claude-opus-4.5-high-reasoning-distill-gguf/llms.txt Demonstrates how to run the GLM-4.7-Flash-Claude-4.5-Opus model using the llama.cpp command-line interface for different tasks. ```APIDOC ## llama-cli ### Description Run the model directly using llama.cpp with specified sampling parameters. ### Method CLI Command ### Endpoint N/A (Local execution) ### Parameters #### Path Parameters - **-m** (string) - Required - Path to the GGUF model file (e.g., `glm-4.7-flash-claude-4.5-opus.q4_k_m.gguf`). #### Query Parameters - **--temp** (float) - Optional - Temperature for sampling. Controls randomness. Defaults vary. - **--top-p** (float) - Optional - Nucleus sampling probability. Defaults vary. - **--min-p** (float) - Optional - Minimum probability for sampling. Defaults vary. - **--repeat-penalty** (float) - Optional - Penalty for repeating tokens. Defaults vary. - **-p** (string) - Required - The input prompt for the model. ### Request Example (General Use) ```bash ./llama-cli -m glm-4.7-flash-claude-4.5-opus.q4_k_m.gguf \ --temp 1.0 \ --top-p 0.95 \ --min-p 0.01 \ --repeat-penalty 1.0 \ -p "Explain quantum entanglement in simple terms" ``` ### Request Example (Tool-calling/Coding Tasks) ```bash ./llama-cli -m glm-4.7-flash-claude-4.5-opus.q4_k_m.gguf \ --temp 0.7 \ --top-p 1.0 \ --min-p 0.01 \ -p "Write a Python class for a binary search tree" ``` ### Response Output is printed directly to the console. #### Success Response (Console Output) - Text generated by the model based on the prompt and parameters. #### Response Example ```text Quantum entanglement is a phenomenon where two or more quantum particles become linked in such a way that they share the same fate, regardless of the distance separating them. Measuring a property of one particle instantaneously influences the corresponding property of the other particle(s). This connection is often described as 'spooky action at a distance' by Einstein. ``` ``` -------------------------------- ### Quantization Options Source: https://context7.com/teichai/glm-4.7-flash-claude-opus-4.5-high-reasoning-distill-gguf/llms.txt Lists available quantization options for the GLM-4.7-Flash-Claude-4.5-Opus model, detailing their file names, quality, and use cases. ```APIDOC ## Quantization Options ### Description Select the appropriate quantization level based on your hardware capabilities and desired balance between model quality and resource consumption. ### Table | Quantization Level | File Name Pattern | Description | |--------------------|-------------------------------------------------------|---------------------------------------------------------| | `bf16` | `glm-4.7-flash-claude-4.5-opus.bf16.gguf` | Highest quality, requires bfloat16 hardware support. | | `f16` | `glm-4.7-flash-claude-4.5-opus.f16.gguf` | High quality, standard float16 precision. | | `q8_0` | `glm-4.7-flash-claude-4.5-opus.q8_0.gguf` | Near-lossless 8-bit quantization, good balance. | | `q6_k` | `glm-4.7-flash-claude-4.5-opus.q6_k.gguf` | High quality 6-bit quantization. | | `q5_k_m` | `glm-4.7-flash-claude-4.5-opus.q5_k_m.gguf` | Balanced quality and file size, good all-around option. | | `q4_k_m` | `glm-4.7-flash-claude-4.5-opus.q4_k_m.gguf` | Recommended default, good quality with smaller size. | | `q3_k_m` | `glm-4.7-flash-claude-4.5-opus.q3_k_m.gguf` | Smaller file size, acceptable quality for resource limits.| | `iq4_nl` | `glm-4.7-flash-claude-4.5-opus.iq4_nl.gguf` | Importance-weighted 4-bit quantization, efficient. | | `iq3_m` | `glm-4.7-flash-claude-4.5-opus.iq3_m.gguf` | Importance-weighted 3-bit quantization, very small size.| | `iq2_m` | `glm-4.7-flash-claude-4.5-opus.iq2_m.gguf` | Smallest size, lower quality, for minimal resource use. | ### Downloading a Quantized Model ```bash huggingface-cli download TeichAI/GLM-4.7-Flash-Claude-Opus-4.5-High-Reasoning-Distill-GGUF \ glm-4.7-flash-claude-4.5-opus.q4_k_m.gguf \ --local-dir ./models ``` ``` -------------------------------- ### Run GLM-4.7-Flash-Claude-Opus with Ollama Source: https://context7.com/teichai/glm-4.7-flash-claude-opus-4.5-high-reasoning-distill-gguf/llms.txt Instructions for loading and running the GLM-4.7-Flash-Claude-4.5-Opus model using Ollama. This includes creating the model from a Modelfile, running it interactively, and making API calls with curl. ```bash # Create the model from the Modelfile ollama create glm-claude-opus -f Modelfile # Run the model interactively ollama run glm-claude-opus # Run with a specific prompt ollama run glm-claude-opus "Explain the concept of recursion in programming" # API usage with curl curl http://localhost:11434/api/generate -d '{ "model": "glm-claude-opus", "prompt": "Write a Python function to calculate factorial", "stream": false }' ``` -------------------------------- ### Chat Template Format Source: https://context7.com/teichai/glm-4.7-flash-claude-opus-4.5-high-reasoning-distill-gguf/llms.txt Illustrates the specific chat template format required for multi-turn conversations with the GLM-4.7 model. ```APIDOC ## Chat Template Format ### Description Use the GLM-4.7 chat template format for structuring multi-turn conversations to ensure the model understands the context and roles. ### Format ```text [gMASK]<|system|> {system_message}<|user|> {user_message}<|assistant|> ``` ### Parameters - **[gMASK]** - Special token indicating the start of a masked generation. - **** - Special token indicating the start of a new prompt. - **<|system|>** - Role token for the system message. - **{system_message}** - The system prompt or instructions. - **<|user|>** - Role token for the user message. - **{user_message}** - The user's input or query. - **<|assistant|>** - Role token indicating the start of the assistant's response. ### Python Example ```python def format_glm_prompt(system: str, user: str) -> str: return f"[gMASK]<|system|>\n{system}<|user|>\n{user}<|assistant|>\n" system_prompt = "You are an expert programmer." user_query = "Write a function to check if a number is prime." formatted_prompt = format_glm_prompt(system_prompt, user_query) print(formatted_prompt) ``` ### Example Output ```text [gMASK]<|system|> You are an expert programmer.<|user|> Write a function to check if a number is prime.<|assistant|> ``` ``` -------------------------------- ### Ollama API - Generate Source: https://context7.com/teichai/glm-4.7-flash-claude-opus-4.5-high-reasoning-distill-gguf/llms.txt This endpoint generates a response from the model based on a given prompt. It supports streaming responses and can be used with various models available in Ollama. ```APIDOC ## POST /api/generate ### Description Generates a text completion or response from the specified model based on the provided prompt. ### Method POST ### Endpoint `http://localhost:11434/api/generate` ### Parameters #### Request Body - **model** (string) - Required - The name of the model to use (e.g., `glm-claude-opus`). - **prompt** (string) - Required - The input text prompt for the model. - **stream** (boolean) - Optional - If true, the response will be streamed in chunks. Defaults to false. ### Request Example ```json { "model": "glm-claude-opus", "prompt": "Write a Python function to calculate factorial", "stream": false } ``` ### Response #### Success Response (200) - **response** (string) - The generated text response from the model. - **done** (boolean) - Indicates if the generation is complete. - **model** (string) - The name of the model used. #### Response Example ```json { "model": "glm-claude-opus", "created_at": "2023-10-30T10:00:00.123Z", "response": "def factorial(n):\n if n == 0:\n return 1\n else:\n return n * factorial(n-1)", "done": true, "context": [1, 2, 3, ...], "total_duration": 1234567890, "load_duration": 12345678, "prompt_eval_count": 10, "prompt_eval_duration": 1234567, "eval_count": 50, "eval_duration": 12345678 } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.