Spaces:
Runtime error
Runtime error
Download llama-cpp-python/tests/test_llama_speculative.py from aelitta/BioMistral_gradio: direct link, hf CLI and curl.
- Browser
- Download file 696 Bytes
-
https://huggingface.co/spaces/aelitta/BioMistral_gradio/resolve/main/llama-cpp-python/tests/test_llama_speculative.py
- Command line
-
hf download hf://spaces/aelitta/BioMistral_gradio/llama-cpp-python/tests/test_llama_speculative.py
-
curl -L -o test_llama_speculative.py https://huggingface.co/spaces/aelitta/BioMistral_gradio/resolve/main/llama-cpp-python/tests/test_llama_speculative.py
696 Bytes
| import numpy as np | |
| from llama_cpp.llama_speculative import LlamaPromptLookupDecoding | |
| def test_find_candidate_pred_tokens(): | |
| find_candidate_pred_tokens = LlamaPromptLookupDecoding.find_candidate_pred_tokens | |
| # Test Case 1: Matching ngram is found | |
| input_ids1 = np.array([1, 2, 3, 1, 2, 3, 1, 2, 3]) | |
| result1 = find_candidate_pred_tokens(input_ids1, max_ngram_size=3, num_pred_tokens=2) | |
| assert np.array_equal(result1, np.array([1, 2])) | |
| # Test Case 2: Matching ngram is not found | |
| input_ids2 = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9]) | |
| result2 = find_candidate_pred_tokens(input_ids2, max_ngram_size=3, num_pred_tokens=2) | |
| assert np.array_equal(result2, np.array([])) | |