Text Generation
MLX
Safetensors
English
gpt2
lottery
time-series
transformer
apple-silicon
causal-lm
idaho-pick3
conversational
Instructions to use curia007/pick3_llm_model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use curia007/pick3_llm_model with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("curia007/pick3_llm_model") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use curia007/pick3_llm_model with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "curia007/pick3_llm_model"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "curia007/pick3_llm_model" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8080/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "curia007/pick3_llm_model", "messages": [ {"role": "user", "content": "Hello"} ] }' - Atomic Chat
Upload Idaho Pick 3 Transformer checkpoint and artifacts
Browse files- config.json +4 -4
- model.safetensors +2 -2
- pick3_hf_model.py +119 -0
- tokenizer_config.json +1 -1
config.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
{
|
| 2 |
"model_type": "gpt2",
|
| 3 |
"vocab_size": 17,
|
| 4 |
-
"max_position_embeddings":
|
| 5 |
"hidden_size": 64,
|
| 6 |
"num_attention_heads": 4,
|
| 7 |
"num_hidden_layers": 3,
|
|
@@ -26,13 +26,13 @@
|
|
| 26 |
"AutoConfig": "pick3_hf_model.Pick3HFConfig",
|
| 27 |
"AutoModelForCausalLM": "pick3_hf_model.Pick3ForCausalLM"
|
| 28 |
},
|
| 29 |
-
"n_positions":
|
| 30 |
-
"n_ctx":
|
| 31 |
"n_embd": 64,
|
| 32 |
"n_layer": 3,
|
| 33 |
"n_head": 4,
|
| 34 |
"n_inner": 256,
|
| 35 |
"activation_function": "gelu",
|
| 36 |
-
"max_seq_len":
|
| 37 |
"mlp_ratio": 4
|
| 38 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"model_type": "gpt2",
|
| 3 |
"vocab_size": 17,
|
| 4 |
+
"max_position_embeddings": 64,
|
| 5 |
"hidden_size": 64,
|
| 6 |
"num_attention_heads": 4,
|
| 7 |
"num_hidden_layers": 3,
|
|
|
|
| 26 |
"AutoConfig": "pick3_hf_model.Pick3HFConfig",
|
| 27 |
"AutoModelForCausalLM": "pick3_hf_model.Pick3ForCausalLM"
|
| 28 |
},
|
| 29 |
+
"n_positions": 64,
|
| 30 |
+
"n_ctx": 64,
|
| 31 |
"n_embd": 64,
|
| 32 |
"n_layer": 3,
|
| 33 |
"n_head": 4,
|
| 34 |
"n_inner": 256,
|
| 35 |
"activation_function": "gelu",
|
| 36 |
+
"max_seq_len": 64,
|
| 37 |
"mlp_ratio": 4
|
| 38 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d877147dcb970fa9e606e2e7a1eaa080ededd8a36c9de6d89e8aafd99a296bbc
|
| 3 |
+
size 624335
|
pick3_hf_model.py
CHANGED
|
@@ -231,6 +231,48 @@ class Pick3HFHub:
|
|
| 231 |
|
| 232 |
DEFAULT_CACHE_DIR = Path.home() / ".cache" / "lottery_ai" / "hub"
|
| 233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
@staticmethod
|
| 235 |
def is_hf_repo_id(repo_id_or_path: Union[str, Path]) -> bool:
|
| 236 |
"""Determines whether a string represents a Hugging Face Hub repository identifier."""
|
|
@@ -853,6 +895,83 @@ if torch is not None and nn is not None:
|
|
| 853 |
pt_state[k] = torch.from_numpy(arr)
|
| 854 |
self.load_state_dict(pt_state, strict=False)
|
| 855 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 856 |
else:
|
| 857 |
# Minimal stub when PyTorch is not available
|
| 858 |
class Pick3ForCausalLM:
|
|
|
|
| 231 |
|
| 232 |
DEFAULT_CACHE_DIR = Path.home() / ".cache" / "lottery_ai" / "hub"
|
| 233 |
|
| 234 |
+
@classmethod
|
| 235 |
+
def decode_response_text(
|
| 236 |
+
cls,
|
| 237 |
+
token_ids: Sequence[int],
|
| 238 |
+
alternative_tickets: Optional[Sequence[Any]] = None,
|
| 239 |
+
prob_matrix: Optional[Any] = None,
|
| 240 |
+
draw_type: Optional[str] = "Night",
|
| 241 |
+
include_narrative: bool = False,
|
| 242 |
+
) -> str:
|
| 243 |
+
"""
|
| 244 |
+
Decodes a token sequence into localized natural language prediction text.
|
| 245 |
+
e.g., 'The next winning Pick 3 numbers are 1 2 3.'
|
| 246 |
+
"""
|
| 247 |
+
from idaho.pick3.pick3_llm_ticket_model import Pick3Tokenizer
|
| 248 |
+
tok = Pick3Tokenizer()
|
| 249 |
+
return tok.decode_response_text(
|
| 250 |
+
token_ids=token_ids,
|
| 251 |
+
alternative_tickets=alternative_tickets,
|
| 252 |
+
prob_matrix=prob_matrix,
|
| 253 |
+
draw_type=draw_type,
|
| 254 |
+
include_narrative=include_narrative,
|
| 255 |
+
)
|
| 256 |
+
|
| 257 |
+
@classmethod
|
| 258 |
+
def format_localized_response(
|
| 259 |
+
cls,
|
| 260 |
+
predicted_digits: Sequence[int],
|
| 261 |
+
prob_matrix: Optional[Any] = None,
|
| 262 |
+
alternative_tickets: Optional[Sequence[Any]] = None,
|
| 263 |
+
draw_type: Optional[str] = "Night",
|
| 264 |
+
) -> Dict[str, str]:
|
| 265 |
+
"""
|
| 266 |
+
Formats predicted lottery digits into a structured localized response dictionary.
|
| 267 |
+
"""
|
| 268 |
+
from idaho.pick3.pick3_llm_ticket_model import format_pick3_localized_response
|
| 269 |
+
return format_pick3_localized_response(
|
| 270 |
+
predicted_digits=predicted_digits,
|
| 271 |
+
prob_matrix=prob_matrix,
|
| 272 |
+
alternative_tickets=alternative_tickets,
|
| 273 |
+
draw_type=draw_type,
|
| 274 |
+
)
|
| 275 |
+
|
| 276 |
@staticmethod
|
| 277 |
def is_hf_repo_id(repo_id_or_path: Union[str, Path]) -> bool:
|
| 278 |
"""Determines whether a string represents a Hugging Face Hub repository identifier."""
|
|
|
|
| 895 |
pt_state[k] = torch.from_numpy(arr)
|
| 896 |
self.load_state_dict(pt_state, strict=False)
|
| 897 |
|
| 898 |
+
def generate_response_text(
|
| 899 |
+
self,
|
| 900 |
+
prompt_tokens: Optional[Sequence[int]] = None,
|
| 901 |
+
history_draws: Optional[Sequence[Dict[str, Any]]] = None,
|
| 902 |
+
draw_type: str = "Night",
|
| 903 |
+
temperature: float = 0.8,
|
| 904 |
+
include_narrative: bool = False,
|
| 905 |
+
) -> str:
|
| 906 |
+
"""
|
| 907 |
+
Generates next Pick 3 draw digits and decodes into localized natural language text.
|
| 908 |
+
e.g., 'The next winning Pick 3 numbers are 1 2 3.'
|
| 909 |
+
"""
|
| 910 |
+
from idaho.pick3.pick3_llm_ticket_model import Pick3Tokenizer
|
| 911 |
+
tokenizer = Pick3Tokenizer()
|
| 912 |
+
if prompt_tokens is None:
|
| 913 |
+
if history_draws is None:
|
| 914 |
+
raise ValueError("Either prompt_tokens or history_draws must be provided")
|
| 915 |
+
prompt_tokens = tokenizer.encode_history_prompt(history_draws, target_draw_type=draw_type)
|
| 916 |
+
|
| 917 |
+
curr_input = list(prompt_tokens)
|
| 918 |
+
gen_tokens = []
|
| 919 |
+
self.eval()
|
| 920 |
+
with torch.no_grad():
|
| 921 |
+
for _ in range(3):
|
| 922 |
+
inp = torch.tensor([curr_input], dtype=torch.long)
|
| 923 |
+
out = self(inp)
|
| 924 |
+
step_logits = out["logits"][0, -1, :10]
|
| 925 |
+
if temperature <= 0.01:
|
| 926 |
+
next_tok = int(torch.argmax(step_logits).item())
|
| 927 |
+
else:
|
| 928 |
+
probs = F.softmax(step_logits / max(temperature, 1e-4), dim=-1)
|
| 929 |
+
next_tok = int(torch.multinomial(probs, num_samples=1).item())
|
| 930 |
+
gen_tokens.append(next_tok)
|
| 931 |
+
curr_input.append(next_tok)
|
| 932 |
+
|
| 933 |
+
return tokenizer.decode_response_text(
|
| 934 |
+
gen_tokens,
|
| 935 |
+
draw_type=draw_type,
|
| 936 |
+
include_narrative=include_narrative,
|
| 937 |
+
)
|
| 938 |
+
|
| 939 |
+
def generate_localized_prediction(
|
| 940 |
+
self,
|
| 941 |
+
prompt_tokens: Optional[Sequence[int]] = None,
|
| 942 |
+
history_draws: Optional[Sequence[Dict[str, Any]]] = None,
|
| 943 |
+
draw_type: str = "Night",
|
| 944 |
+
temperature: float = 0.8,
|
| 945 |
+
) -> Dict[str, str]:
|
| 946 |
+
"""Generates localized prediction dictionary with primary, alternatives, and permutations."""
|
| 947 |
+
from idaho.pick3.pick3_llm_ticket_model import Pick3Tokenizer
|
| 948 |
+
tokenizer = Pick3Tokenizer()
|
| 949 |
+
if prompt_tokens is None:
|
| 950 |
+
if history_draws is None:
|
| 951 |
+
raise ValueError("Either prompt_tokens or history_draws must be provided")
|
| 952 |
+
prompt_tokens = tokenizer.encode_history_prompt(history_draws, target_draw_type=draw_type)
|
| 953 |
+
|
| 954 |
+
curr_input = list(prompt_tokens)
|
| 955 |
+
gen_tokens = []
|
| 956 |
+
self.eval()
|
| 957 |
+
with torch.no_grad():
|
| 958 |
+
for _ in range(3):
|
| 959 |
+
inp = torch.tensor([curr_input], dtype=torch.long)
|
| 960 |
+
out = self(inp)
|
| 961 |
+
step_logits = out["logits"][0, -1, :10]
|
| 962 |
+
if temperature <= 0.01:
|
| 963 |
+
next_tok = int(torch.argmax(step_logits).item())
|
| 964 |
+
else:
|
| 965 |
+
probs = F.softmax(step_logits / max(temperature, 1e-4), dim=-1)
|
| 966 |
+
next_tok = int(torch.multinomial(probs, num_samples=1).item())
|
| 967 |
+
gen_tokens.append(next_tok)
|
| 968 |
+
curr_input.append(next_tok)
|
| 969 |
+
|
| 970 |
+
return tokenizer.decode_response(
|
| 971 |
+
gen_tokens,
|
| 972 |
+
draw_type=draw_type,
|
| 973 |
+
)
|
| 974 |
+
|
| 975 |
else:
|
| 976 |
# Minimal stub when PyTorch is not available
|
| 977 |
class Pick3ForCausalLM:
|
tokenizer_config.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
"eos_token": "<EOS>",
|
| 7 |
"pad_token": "<PAD>",
|
| 8 |
"unk_token": "[UNK]",
|
| 9 |
-
"model_max_length":
|
| 10 |
"clean_up_tokenization_spaces": false,
|
| 11 |
"chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<BOS>' }}{% endif %}{% if message['role'] == 'system' %}{{ '<BOS>' + message['content'].strip() + ' ' }}{% elif message['role'] == 'user' %}{% if not loop.first and messages[loop.index0 - 1]['role'] == 'assistant' %}{{ ' ' }}{% endif %}{{ message['content'].strip() + ' <PRED>' }}{% elif message['role'] == 'assistant' %}{{ ' ' + message['content'].strip() + ' <EOS>' }}{% endif %}{% endfor %}{% if add_generation_prompt and messages[-1]['role'] != 'assistant' %}{{ ' ' }}{% endif %}",
|
| 12 |
"added_tokens_decoder": {
|
|
|
|
| 6 |
"eos_token": "<EOS>",
|
| 7 |
"pad_token": "<PAD>",
|
| 8 |
"unk_token": "[UNK]",
|
| 9 |
+
"model_max_length": 64,
|
| 10 |
"clean_up_tokenization_spaces": false,
|
| 11 |
"chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<BOS>' }}{% endif %}{% if message['role'] == 'system' %}{{ '<BOS>' + message['content'].strip() + ' ' }}{% elif message['role'] == 'user' %}{% if not loop.first and messages[loop.index0 - 1]['role'] == 'assistant' %}{{ ' ' }}{% endif %}{{ message['content'].strip() + ' <PRED>' }}{% elif message['role'] == 'assistant' %}{{ ' ' + message['content'].strip() + ' <EOS>' }}{% endif %}{% endfor %}{% if add_generation_prompt and messages[-1]['role'] != 'assistant' %}{{ ' ' }}{% endif %}",
|
| 12 |
"added_tokens_decoder": {
|