Skip to content

convert : add phi-3 support #6851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

convert : add phi-3 support #6851

wants to merge 2 commits into from

Conversation

ggerganov
Copy link
Member

@ggerganov ggerganov commented Apr 23, 2024

ref #6849

Modelling this as LLaMA model since it is the same arch

Model: https://huggingface.co/microsoft/Phi-3-mini-4k-instruct

# convert to GGUF
python3 convert-hf-to-gguf.py ~/Data/huggingface/Phi-3-mini-4k-instruct/ --outfile models/phi-3-4k-instruct/ggml-model-f16.gguf --outtype f16
# sample run
./main -m models/phi-3-4k-instruct/ggml-model-f16.gguf -e -p "<|system|>\nYou are a helpful AI assistant.<|end|>\n<|user|>\nHow to explain Internet for a medieval knight?<|end|>\n<|assistant|>" --temp 0.1 --verbose-prompt
system_info: n_threads = 16 / 24 | AVX = 0 | AVX_VNNI = 0 | AVX2 = 0 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | FMA = 0 | NEON = 1 | ARM_FMA = 1 | F16C = 0 | FP16_VA = 1 | WASM_SIMD = 0 | BLAS = 1 | SSE3 = 0 | SSSE3 = 0 | VSX = 0 | MATMUL_INT8 = 0 | 

main: prompt: '<|system|>
You are a helpful AI assistant.<|end|>
<|user|>
How to explain Internet for a medieval knight?<|end|>
<|assistant|>'
main: number of tokens in prompt = 28
     1 -> '<s>'
 32006 -> '<|system|>'
    13 -> '
'
  3492 -> 'You'
   526 -> ' are'
   263 -> ' a'
  8444 -> ' helpful'
   319 -> ' A'
 29902 -> 'I'
 20255 -> ' assistant'
 29889 -> '.'
 32007 -> '<|end|>'
    13 -> '
'
 32010 -> '<|user|>'
    13 -> '
'
  5328 -> 'How'
   304 -> ' to'
  5649 -> ' explain'
  4685 -> ' Internet'
   363 -> ' for'
   263 -> ' a'
 27690 -> ' medieval'
   889 -> ' kn'
   523 -> 'ight'
 29973 -> '?'
 32007 -> '<|end|>'
    13 -> '
'
 32001 -> '<|assistant|>'

sampling: 
	repeat_last_n = 64, repeat_penalty = 1.000, frequency_penalty = 0.000, presence_penalty = 0.000
	top_k = 40, tfs_z = 1.000, top_p = 0.950, min_p = 0.050, typical_p = 1.000, temp = 0.100
	mirostat = 0, mirostat_lr = 0.100, mirostat_ent = 5.000
sampling order: 
CFG -> Penalties -> top_k -> tfs_z -> typical_p -> top_p -> min_p -> temperature 
generate: n_ctx = 512, n_batch = 2048, n_predict = -1, n_keep = 1


<s><|system|>
You are a helpful AI assistant.<|end|>
<|user|>
How to explain Internet for a medieval knight?<|end|>
<|assistant|> My noble knight, imagine the vast kingdom of knowledge and communication that exists beyond the walls of your castle, known as the "Internet." It is a magical realm where information flows freely, connecting people from all corners of the world, much like the messengers and couriers of your time.

1. The Internet is akin to a grand library, containing countless scrolls and tomes, but instead of being confined to a single location, it exists in the ether, accessible to all who possess the knowledge to navigate it.

2. To access this realm, one must possess a magical artifact called a "computer," which is a small, enchanted device that allows you to interact with the Internet. This device is powered by a mystical force called electricity, which flows through it like lifeblood.

3. The Internet is divided into various kingdoms, each with its own purpose and inhabitants. Some kingdoms are dedicated to sharing knowledge, such as the "World Wide Web," where information is stored in the form of "web pages" that can be accessed by anyone with the right tools.

4. Other kingdoms are dedicated to communication, such as "email," where messages are sent instantly to distant lands, much like a swift horse carrying a letter.

5. There are also kingdoms dedicated to entertainment, such as "streaming services," where one can watch moving pictures and listen to music from the comfort of their own quarters.

6. To navigate this vast realm, one must learn the language of the Internet, which is composed of symbols and codes known as "URLs" (Uniform Resource Locators) and "hyperlinks." These symbols and codes act as magical portals, allowing you to travel from one kingdom to another.

7. To ensure your safety and security within the Internet realm, it is essential to be aware of the presence of "hackers" and "scammers," who may seek to mislead or harm you. To protect yourself, you must learn to recognize and avoid these dangers.

8. Finally, the Internet is a place of endless possibilities, where you can learn, connect, and explore new ideas and cultures. It is a powerful tool that can help you grow and evolve as a person, but it is essential to use it wisely and responsibly.

In conclusion, the Internet is a vast and complex realm that offers countless opportunities for learning, communication, and entertainment. By understanding its language and navigating its kingdoms with caution, you can unlock its full potential and embark on a journey of discovery and growth.<|endoftext|> [end of text]

llama_print_timings:        load time =     241.00 ms
llama_print_timings:      sample time =      10.12 ms /   567 runs   (    0.02 ms per token, 56005.53 tokens per second)
llama_print_timings: prompt eval time =      41.69 ms /    28 tokens (    1.49 ms per token,   671.62 tokens per second)
llama_print_timings:        eval time =    9834.94 ms /   566 runs   (   17.38 ms per token,    57.55 tokens per second)
llama_print_timings:       total time =    9937.26 ms /   594 tokens

Sometimes it is producing some new tokens such as <|calc|>, <|/data|> and <|code|> - not sure what are those. (this was a tokenizer issue: #6852 (comment))

Haven't looked in 128k support yet

@ggerganov
Copy link
Member Author

Merged #6852 instead since the implementation is better and faster

@ggerganov ggerganov closed this Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant