Text Generation
Transformers
ONNX
PyTorch
English
symbolic-decoder
aletheia
philosophical-agi
gnai-creator
Run this model with HF Jobs
Run gnai-creator/noesis-decoder on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/gnai-creator/noesis-decoder. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/gnai-creator/noesis-decoder on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/gnai-creator/noesis-decoder. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/gnai-creator/noesis-decoder. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use gnai-creator/noesis-decoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use gnai-creator/noesis-decoder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="gnai-creator/noesis-decoder")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("gnai-creator/noesis-decoder", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use gnai-creator/noesis-decoder with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "gnai-creator/noesis-decoder" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gnai-creator/noesis-decoder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/gnai-creator/noesis-decoder
- SGLang
How to use gnai-creator/noesis-decoder with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "gnai-creator/noesis-decoder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gnai-creator/noesis-decoder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "gnai-creator/noesis-decoder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gnai-creator/noesis-decoder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use gnai-creator/noesis-decoder with Docker Model Runner:
docker model run hf.co/gnai-creator/noesis-decoder
Upload handler.py
Browse files20 unmodified lines212223242526272829350 unmodified lines38038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944029 unmodified lines47047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453520 unmodified linesfrom dataclasses import dataclassfrom pathlib import Pathimport hashlibimport randomimport refrom typing import Any, Mapping, MutableMapping, Optional, Sequenceimport numpy as np350 unmodified linesreturn self._coerce_array(value, node=node)def _encode_tokens(self, text: str) -> tuple[np.ndarray, list[int]]:token_ids = self._tokenizer.encode(text)if self._token_sequence_length <= 0:array = np.asarray([token_ids], dtype=self._token_dtype)return array, token_idslength = min(len(token_ids), self._token_sequence_length)padded = np.full((1, self._token_sequence_length),fill_value=self._tokenizer.pad_token_id,dtype=self._token_dtype,)padded[0, :length] = np.asarray(token_ids[:length], dtype=self._token_dtype)return padded, token_ids[:length]@staticmethoddef _candidate_seed(psi: np.ndarray) -> int:digest = hashlib.sha1(psi.tobytes()).digest()return int.from_bytes(digest[:4], "little", signed=False)def _build_candidates(self,psi_vector: np.ndarray,*,user_prompt: str | None,system_prompt: str | None,constraints: Mapping[str, Any] | None,) -> tuple[list[str], str, list[str]]:descriptors = _summarise_intent(psi_vector)summary = ", ".join(descriptors) if descriptors else "balanced intent"observations = [f"Interpretation: the symbolic intent emphasises {summary}.",f"Symbolic synopsis → {summary}.",]if user_prompt:observations.append(f"{user_prompt.strip()}\nInsight: {summary}.")if system_prompt:observations.append(f"{system_prompt.strip()}\nDirective: honour {summary}.")if constraints:formatted = ", ".join(f"{key}={value}" for key, value in constraints.items())observations.append(f"Constraints observed: {formatted}.")seed = self._candidate_seed(psi_vector.astype(np.float32, copy=False))rng = random.Random(seed)rng.shuffle(observations)if not observations:observations = [f"Symbolic synopsis → {summary}."]return observations, summary, descriptorsdef _run_candidate(self, base_feed: Mapping[str, np.ndarray], tokens: np.ndarray) -> list[tuple[Any, np.ndarray]]:feed = {name: value for name, value in base_feed.items()}if self.tokens_input is not None:feed[self.tokens_input] = tokensoutputs = self.session.run(None, feed)return list(zip(self.io.outputs, outputs))@staticmethoddef _extract_q_hat(outputs: Sequence[tuple[Any, np.ndarray]]) -> float:29 unmodified linessystem_prompt = payload.get("system_prompt")user_prompt = payload.get("user_prompt")candidates, summary, descriptors = self._build_candidates(psi_vector,user_prompt=user_prompt if isinstance(user_prompt, str) else None,system_prompt=system_prompt if isinstance(system_prompt, str) else None,constraints=state_constraints,)best_text: str | None = Nonebest_tokens: list[int] = []best_outputs: list[tuple[Any, np.ndarray]] | None = Nonebest_quality = float("-inf")limit = min(len(candidates), max(decoding.beam_size, 1))for candidate in candidates[:limit]:if self.tokens_input is None:breaktoken_array, token_ids = self._encode_tokens(candidate)outputs = self._run_candidate(feed, token_array)quality = self._extract_q_hat(outputs)if quality > best_quality:best_quality = qualitybest_text = candidatebest_tokens = token_idsbest_outputs = outputsif quality >= decoding.stop_quality:breakif best_outputs is None:# Fall back to a single pass using the prepared feed.outputs = self.session.run(None, feed)best_outputs = list(zip(self.io.outputs, outputs))if best_text is None:best_text = f"Symbolic synopsis → {summary}."if best_quality == float("-inf"):best_quality = self._extract_q_hat(best_outputs)formatted = {node.name: self._format_output(node.name, value)for node, value in best_outputs}if not np.isfinite(best_quality):best_quality = 0.0best_quality = float(best_quality)if best_text is None:best_text = f"Symbolic synopsis → {summary}."response = {"text": best_text,"tokens": best_tokens,"quality": best_quality,"q_hat": best_quality,"provider": _DEFAULT_PROVIDER,"model": _DEFAULT_MODEL,"metadata": {"summary": summary,"descriptors": descriptors,"constraints": state_constraints or {},"decoding": decoding.to_dict(),},}response.update(formatted)return response20 unmodified lines2122232425262728350 unmodified lines37938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051129 unmodified lines54154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161220 unmodified linesfrom dataclasses import dataclassfrom pathlib import Pathimport hashlibimport refrom typing import Any, Mapping, MutableMapping, Optional, Sequence, Tupleimport numpy as np350 unmodified linesreturn self._coerce_array(value, node=node)@staticmethoddef _candidate_seed(psi: np.ndarray) -> int:digest = hashlib.sha1(psi.tobytes()).digest()return int.from_bytes(digest[:4], "little", signed=False)def _token_array_from_ids(self, token_ids: Sequence[int]) -> np.ndarray:ids = list(token_ids)if self._token_sequence_length <= 0:return np.asarray([ids], dtype=self._token_dtype)padded = np.full((1, self._token_sequence_length),fill_value=self._tokenizer.pad_token_id,dtype=self._token_dtype,)length = min(len(ids), self._token_sequence_length)if length > 0:padded[0, :length] = np.asarray(ids[:length], dtype=self._token_dtype)return paddeddef _run_candidate(self, base_feed: Mapping[str, np.ndarray], tokens: Sequence[int]) -> list[tuple[Any, np.ndarray]]:feed = {name: (value.copy() if isinstance(value, np.ndarray) else value)for name, value in base_feed.items()}if self.tokens_input is not None:feed[self.tokens_input] = self._token_array_from_ids(tokens)outputs = self.session.run(None, feed)return list(zip(self.io.outputs, outputs))@staticmethoddef _extract_logits(outputs: Sequence[tuple[Any, np.ndarray]]) -> Optional[np.ndarray]:for node, value in outputs:if getattr(node, "name", "").lower() == "logits":return np.asarray(value, dtype=np.float32)if outputs:return np.asarray(outputs[0][1], dtype=np.float32)return None@staticmethoddef _sample_next_token(logits: np.ndarray,decoding: _DecodingParams,rng: np.random.Generator,) -> int:vector = np.asarray(logits, dtype=np.float64).reshape(-1)temperature = max(float(decoding.temperature), 1e-5)top_p = float(decoding.top_p)if temperature <= 1e-5 or not np.isfinite(vector).any():return int(int(np.argmax(vector)))stabilized = vector / temperaturestabilized -= np.max(stabilized)probs = np.exp(stabilized)probs = np.nan_to_num(probs, nan=0.0, posinf=0.0, neginf=0.0)total = probs.sum()if total <= 0.0:return int(np.argmax(vector))probs /= totalif top_p <= 0.0:return int(np.argmax(probs))if 0.0 < top_p < 1.0:sorted_indices = np.argsort(-probs)sorted_probs = probs[sorted_indices]cumulative = np.cumsum(sorted_probs)mask = cumulative <= top_pif mask.size > 0:mask[0] = Truefiltered_indices = sorted_indices[mask]filtered_probs = sorted_probs[mask]filtered_total = filtered_probs.sum()if filtered_total <= 0.0:filtered_indices = sorted_indicesfiltered_probs = sorted_probsfiltered_total = filtered_probs.sum()filtered_probs = filtered_probs / filtered_totalchoice = rng.choice(len(filtered_indices), p=filtered_probs)return int(filtered_indices[int(choice)])choice = rng.choice(len(probs), p=probs)return int(choice)def _generate_sequence(self,base_feed: Mapping[str, np.ndarray],*,decoding: _DecodingParams,seed: int,) -> Optional[Tuple[str, list[int], float, list[tuple[Any, np.ndarray]], int]]:if self.tokens_input is None:return Nonerng = np.random.default_rng(seed)token_ids: list[int] = [self._tokenizer.bos_token_id]quality = float("-inf")formatted_outputs: list[tuple[Any, np.ndarray]] | None = Nonesteps = 0max_steps = max(decoding.max_new_tokens, 1)for _ in range(max_steps):outputs = self._run_candidate(base_feed, token_ids)logits = self._extract_logits(outputs)if logits is None:breaklast_index = min(len(token_ids) - 1, logits.shape[1] - 1)next_logits = logits[0, last_index]next_token = self._sample_next_token(next_logits, decoding, rng)token_ids.append(int(next_token))steps += 1outputs = self._run_candidate(base_feed, token_ids)formatted_outputs = outputsquality = self._extract_q_hat(outputs)if token_ids[-1] == self._tokenizer.eos_token_id:breakif self._token_sequence_length > 0 and len(token_ids) >= self._token_sequence_length:breakif formatted_outputs is None:return Nonetext = self._tokenizer.decode(token_ids)return text, token_ids, float(quality), formatted_outputs, steps@staticmethoddef _extract_q_hat(outputs: Sequence[tuple[Any, np.ndarray]]) -> float:29 unmodified linessystem_prompt = payload.get("system_prompt")user_prompt = payload.get("user_prompt")descriptors = _summarise_intent(psi_vector)summary = ", ".join(descriptors) if descriptors else "balanced intent"best_candidate: Optional[Tuple[str, list[int], float, list[tuple[Any, np.ndarray]], int]] = Noneseeds: list[int] = []if self.tokens_input is not None:beams = max(decoding.beam_size, 1)base_seed = self._candidate_seed(psi_vector)for beam_idx in range(beams):seed = base_seed + beam_idxseeds.append(seed)candidate = self._generate_sequence(feed,decoding=decoding,seed=seed,)if candidate is None:continuetext, token_ids, quality, outputs, steps = candidateif (best_candidate is Noneor quality > best_candidate[2]):best_candidate = candidateif quality >= decoding.stop_quality:breakif best_candidate is None:outputs = self.session.run(None, feed)formatted_outputs = list(zip(self.io.outputs, outputs))quality = self._extract_q_hat(formatted_outputs)text = f"Symbolic synopsis → {summary}."token_ids: list[int] = []steps = 0else:text, token_ids, quality, formatted_outputs, steps = best_candidateformatted = {node.name: self._format_output(node.name, value)for node, value in formatted_outputs}if not np.isfinite(quality):quality = 0.0quality = float(quality)metadata = {"summary": summary,"descriptors": descriptors,"constraints": state_constraints or {},"decoding": decoding.to_dict(),"seeds": seeds,"steps": steps,"system_prompt": system_prompt if isinstance(system_prompt, str) else None,"user_prompt": user_prompt if isinstance(user_prompt, str) else None,}response = {"text": text,"tokens": token_ids,"quality": quality,"q_hat": quality,"provider": _DEFAULT_PROVIDER,"model": _DEFAULT_MODEL,"metadata": metadata,}response.update(formatted)return response
handler.py+170-93