tts

http://xwiki.yzlit.com/english/tts.html

A programming of spatiotemporal composability

Composition—assembling complex systems from simpler parts—is a foundational principle of software engineering. 
Traditionally, composition is static: function calls, module imports, and class inheritance are resolved at compile time and remain fixed throughout execution. 
However, modern software increasingly demands dynamic composition, where components are loaded, unloaded, and reconfigured at runtime. 
Plugin architectures [2] and self-evolving agent harnesses both require systems that can safely add and remove functionality on the fly, yet current practice defers to coarse-grained mechanisms [3] that reconfigure only by restarting, discarding runtime state. 
Despite the growing practical importance of dynamic composition, its theoretical foundations remain underdeveloped, compared to the rich formal frameworks available for static composition.

We have presented a formal foundation for dynamic composability by lifting the classical concepts of effects and coeffects to runtime mechanisms. 
Revertible effects address local temporal composability: every context transformation carries an inverse that the runtime tracks, and both tracking and recovery preserve composition, so the context is recovered upon component removal. 
Reactive coeffects address local spatial composability: a component is notified against its coeffect specification whenever the context changes, each change classified as activating, deactivating, or neutral, with coeffect isolation varying what a declared key resolves to and coeffect interception varying how the binding is used. 
We unify the effect context and the coeffect context into a single context type, in which an observational equivalence on the coeffects supplies the effects with independence, constituting a programming paradigm for spatiotemporal composability. 
Combining these mechanisms into the notion of a component then gives a calculus of dynamic composition, whose metatheory carries spatiotemporal composability from a single component to a whole system of interleaved components. 
We realize this paradigm as the Cordis meta-framework, with a core library providing effect tracking and coeffect resolution, as well as a declarative component loader with configuration reconciliation and hot module replacement. 
The Koishi case study validates the design of Cordis in a production system with over 4000 community plugins.

Beyond human-curated plugin ecosystems, a compelling direction for future validation is self-evolving agent harnesses, where an AI agent generates and replaces its own harness components continuously and with little human oversight. 
Applying Cordis in such a setting would validate the temporal guarantees of complete recovery under rapid component replacement, as well as the spatial guarantees of dependency coordination under frequent topological change. 
Such validation would demonstrate the paradigm’s applicability as a foundation for recoverable, coordinated, and continuous self-evolution in agent harnesses and other autonomous systems.

Different RAG Approachs

Different Retrieval Augmented Generation (RAG) Approaches 

1.Classic RAG
Best when you have well-chunked documents, queries are straightforward, latency & cost matter, and you don't need cross-document reasoning. 
A linear 6-step pipeline: embed query → ANN search → top-K chunks → single LLM call. 
Fast, cheap, but no reasoning capability.

2.Knowledge RAG
Best when entities and relationships are crucial (medical, legal, financial), multi-hop reasoning is required, and you can invest in KG construction. 
Enhances retrieval with entity extraction and KG traversal. 
Surfaces relational/multi-hop facts (e.g. drug → gene → disease) before hitting the LLM. 
Higher accuracy, higher setup cost.

3.Agentic RAG
Best for open-ended research, complex analysis, coding assistants, or any task requiring tool use, planning, and iterative self-correction. 
An orchestrator agent dynamically plans which tools to call (vector search, SQL, APIs, web, code exec), loops through a Reason → Act → Observe cycle, maintains working memory, and self-corrects — producing the most accurate but most expensive results.

4.Hybrid Approaches
Production systems often layer these — Classic RAG as a fast path, KG for structured lookups, and Agentic orchestration for complex queries.

embedding mode

Bi-encoder vs Cross-encoder

Do you know the difference between a bi-encoder and a cross-encoder?

In a bi-encoder, documents and queries are embedded separately by an embedding model. 
Then an ANN algorithm is used by a vector database to rapidly identify documents whose vectors are closest to the query vector.

The most important part here is that document vectors are pre computed. 
It means documents can be embedded ahead of time and only the query itself needs to be embedded at runtime. 
This is the most common approach in RAG pipelines.

On the other hand, we have the Cross Encoder. 
It provides significantly higher quality document rankings than bi encoders, but it is not worth it for every situation.

In a cross-encoder, each document is concatenated with the user query and the pair is sent together through the model. 
Instead of producing separate embeddings, the model performs a deep joint analysis of the interaction between query and document, outputting a relevance score (often normalized, depending on the model). 
This is a much slower approach, since the model has to process every single document-query pair at runtime, but a cross-encoder captures the meaning of a document taking into consideration the user query, not in isolation.

This analogy is a very good one to understand it: Imagine a hiring process with 1000 resumes. 
In the screening stage, an assistant summarizes each resume into a short profile before knowing which job opening will appear. 
When the job shows up, he compares the profiles mathematically. 
It is fast, but since the resumes were summarized without knowing the job description, specific details get lost. 
This is the bi-encoder approach.

The cross-encoder, on the other hand, is the technical interview. 
You take the top 50 candidates from the screening and read each resume side by side with the job description, comparing point by point. 
This is much more precise, but impossible to do with all 1000.

In RAG, both work together: the bi-encoder quickly retrieves the most likely candidates from the vector database and the cross-encoder reranks those candidates with precision before passing them to the LLM. 
Some reranking models, like the Cohere Reranker, are cross-encoder models.

About Pytorch

PyTorch is an open-source Python-based deep learning library. 
According to Papers With Code, a platform that tracks and analyzes research papers, PyTorch has been the most widely used deep learning library for research since 2019 by a wide margin. 
And according to the Kaggle Data Science and Machine Learning Survey 2022, the number of respondents using PyTorch is approximately 40% and constantly grows every year.

## The three core components of PyTorch

One of the reasons why PyTorch is so popular is its user-friendly interface and efficiency. 
However, despite its accessibility, it doesn’t compromise on flexibility, providing advanced users the ability to tweak lower-level aspects of their models for customization and optimization. 
In short, for many practitioners and researchers, PyTorch offers just the right balance between usability and features.

Firstly, PyTorch is a tensor library that extends the concept of array-oriented programming library NumPy with the additional feature of accelerated computation on GPUs, thus providing a seamless switch between CPUs and GPUs.

Secondly, PyTorch is an automatic differentiation engine, also known as autograd, which enables the automatic computation of gradients for tensor operations, simplifying backpropagation and model optimization.

Finally, PyTorch is a deep learning library, meaning that it offers modular, flexible, and efficient building blocks (including pre-trained models, loss functions, and optimizers) for designing and training a wide range of deep learning models, catering to both researchers and developers.

## Defining deep learning

LLMs are often referred to as AI models in the news. 
However, LLMs are also a type of deep neural network, and PyTorch is a deep learning library. 
Sounds confusing? Let’s take a brief moment and summarize the relationship between these terms before we proceed.

AI is fundamentally about creating computer systems capable of performing tasks that usually require human intelligence. 
These tasks include understanding natural language, recognizing patterns, and making decisions. 
(Despite significant progress, AI is still far from achieving this level of general intelligence.)

Machine learning represents a subfield of AI (as illustrated in Figure 2) that focuses on developing and improving learning algorithms. 
The key idea behind machine learning is to enable computers to learn from data and make predictions or decisions without being explicitly programmed to perform the task. 
This involves developing algorithms that can identify patterns and learn from historical data and improve their performance over time with more data and feedback.

Machine learning has been integral in the evolution of AI, powering many of the advancements we see today, including LLMs. 
Machine learning is also behind technologies like recommendation systems used by online retailers and streaming services, email spam filtering, voice recognition in virtual assistants, and even self-driving cars. 
The introduction and advancement of machine learning have significantly enhanced AI’s capabilities, enabling it to move beyond strict rule-based systems and adapt to new inputs or changing environments.

Deep learning is a subcategory of machine learning that focuses on the training and application of deep neural networks. 
These deep neural networks were originally inspired by how the human brain works, particularly the interconnection between many neurons. 
The “deep” in deep learning refers to the multiple hidden layers of artificial neurons or nodes that allow them to model complex, nonlinear relationships in the data.

Unlike traditional machine learning techniques that excel at simple pattern recognition, deep learning is particularly good at handling unstructured data like images, audio, or text, so deep learning is particularly well suited for LLMs.

## Summary

1.PyTorch is an open-source library that consists of three core components: a tensor library, automatic differentiation functions, and deep learning utilities.

2.PyTorch’s tensor library is similar to array libraries like NumPy

3.In the context of PyTorch, tensors are array-like data structures to represent scalars, vectors, matrices, and higher-dimensional arrays.

4.PyTorch tensors can be executed on the CPU, but one major advantage of PyTorch’s tensor format is its GPU support to accelerate computations.

5.The automatic differentiation (autograd) capabilities in PyTorch allow us to conveniently train neural networks using backpropagation without manually deriving gradients.

6.The deep learning utilities in PyTorch provide building blocks for creating custom deep neural networks.

7.PyTorch includes Dataset and DataLoader classes to set up efficient data loading pipelines.

8.It’s easiest to train models on a CPU or single GPU.

9.Using DistributedDataParallel is the simplest way in PyTorch to accelerate the training if multiple GPUs are available.