Skip to content
This repository was archived by the owner on Mar 20, 2026. It is now read-only.

SynapticStrings/QyCore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QyCore

Note

Over 70% code was generated by Claude 4 Opus, but it was abandoned because of its high information density and difficulty in maintenance.

Curretly, the core features of this repository (heavy-duty computing services, caching) have been implemented using other libraries. Interrupted recovery and Nx-integration will be implemented in several smaller libraries in future(Today's 20/03/2026). Therefore, this repository will be archived.

Standing on the shoulder of Orchid.

QyCore integrates OTP to achieve resource management, fault tolerance, data persistence, and recovery.

  • Orchid = DAG + Light Concepts(Scheduler/Executor/Runner/Hooks)
  • QyCore = OTP runtime(Instrument registry + Large param injection + optional persistence/hydrate/dehydrate) + Orchid
  • Quincunx (alternative candidate) = Orchid + OrchisStratum (large param inject and bypass cache) + OrchidSymbiont (close to instrument registry) + Graph declaration and compiling based on nodes and edges (front-end friendly)

Process

Examples

defmodule QyDemo.Models do
  @moduledoc "Model builders for Nx.Serving"

  def build_embedder(opts) do
    model_name = Keyword.get(opts, :model, "sentence-transformers/all-MiniLM-L6-v2")

    {:ok, model_info} = Bumblebee.load_model({:hf, model_name})
    {:ok, tokenizer} = Bumblebee.load_tokenizer({:hf, model_name})

    Bumblebee.Text.TextEmbedding.text_embedding(model_info, tokenizer,
      compile: [batch_size: 32, sequence_length: 128],
      defn_options: [compiler: EXLA]
    )
  end

  def build_classifier(opts) do
    model_name = Keyword.get(opts, :model, "facebook/bart-large-mnli")

    {:ok, model_info} = Bumblebee.load_model({:hf, model_name})
    {:ok, tokenizer} = Bumblebee.load_tokenizer({:hf, model_name})

    labels = Keyword.get(opts, :labels, ["positive", "negative", "neutral"])

    Bumblebee.Text.ZeroShotClassification.zero_shot_classification(
      model_info,
      tokenizer,
      labels,
      compile: [batch_size: 8, sequence_length: 256],
      defn_options: [compiler: EXLA]
    )
  end
end

# In application.ex
children = [
  # QyCore infrastructure
  QyCore.Instruments.NxServing.DynamicSupervisor,
  QyCore.InstrumentRegistry,

  # Local embedding model
  {QyCore.Instruments.NxServing.Supervisor, [
    name: :embedder,
    serving_fn: &QyDemo.Models.build_embedder/1,
    serving_opts: [model: "BAAI/bge-small-en-v1.5"],
    batch_timeout: 50
  ]},

  # Cache
  {QyCore.Instruments.Cache, [
    name: :cache,
    max_entries: 10_000,
    eviction: :lru
  ]}
]

# After supervisor starts:
QyCore.InstrumentRegistry.register(:embedder, QyCore.Instruments.NxServing)
QyCore.InstrumentRegistry.register(:cache, QyCore.Instruments.Cache)

defmodule QyDemo.Steps.EmbedDocument do  
  @behaviour QyCore.Step  
  
  @impl true  
  def instruments, do: [:embedder, :cache]  
  
  @impl true  
  def run(%{text: text}, inst, opts) do  
    # Get embedding from local model  
    {:ok, embedding_ref} = inst.embedder.run_and_store(%{text: text}, opts)  
  
    # Store result in cache  
    {:ok, result_ref} = inst.cache.store(%{  
      text: text,  
      embedding_ref: embedding_ref,  
      embedded_at: DateTime.utc_now()  
    })  
  
    {:ok, %{result: result_ref}}  
  end  
  
  def run(%{text_ref: text_ref}, inst, opts) do  
    with {:ok, %{text: text}} <- inst.cache.fetch(text_ref) do  
      run(%{text: text}, inst, opts)  
    end  
  end  
end

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages