mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-10-31 08:51:55 +00:00 
			
		
		
		
	llama : add llama_vocab, functions -> methods, naming (#11110)
				
					
				
			* llama : functions -> methods (#11110) * llama : add struct llama_vocab to the API (#11156) ggml-ci * hparams : move vocab params to llama_vocab (#11159) ggml-ci * vocab : more pimpl (#11165) ggml-ci * vocab : minor tokenization optimizations (#11160) ggml-ci Co-authored-by: Diego Devesa <slarengh@gmail.com> * lora : update API names (#11167) ggml-ci * llama : update API names to use correct prefix (#11174) * llama : update API names to use correct prefix ggml-ci * cont ggml-ci * cont ggml-ci * minor [no ci] * vocab : llama_vocab_add_[be]os -> llama_vocab_get_add_[be]os (#11174) ggml-ci * vocab : llama_vocab_n_vocab -> llama_vocab_n_tokens (#11174) ggml-ci --------- Co-authored-by: Diego Devesa <slarengh@gmail.com>
This commit is contained in:
		| @@ -23,12 +23,12 @@ defer { | ||||
| } | ||||
|  | ||||
| let model_params = llama_model_default_params() | ||||
| guard let model = llama_load_model_from_file(modelPath.cString(using: .utf8), model_params) else { | ||||
| guard let model = llama_model_load_from_file(modelPath.cString(using: .utf8), model_params) else { | ||||
|     print("Failed to load model") | ||||
|     exit(1) | ||||
| } | ||||
| defer { | ||||
|     llama_free_model(model) | ||||
|     llama_model_free(model) | ||||
| } | ||||
|  | ||||
| var tokens = tokenize(text: prompt, add_bos: true) | ||||
| @@ -141,7 +141,7 @@ while n_cur <= n_len { | ||||
|         let new_token_id = llama_sampler_sample(smpl, context, i_batch[i]) | ||||
|  | ||||
|         // is it an end of stream? -> mark the stream as finished | ||||
|         if llama_token_is_eog(model, new_token_id) || n_cur == n_len { | ||||
|         if llama_vocab_is_eog(model, new_token_id) || n_cur == n_len { | ||||
|             i_batch[i] = -1 | ||||
|             // print("") | ||||
|             if n_parallel > 1 { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Georgi Gerganov
					Georgi Gerganov