IICSM AI research workspaceSign in

A SELF-CONTAINED FIELD GUIDE · VERSION 1

Learn from one example.
Know what that means.

Theory, a working experiment, operating commands, and the limits of this shared-hosting research workspace. The explanations and demo work without external libraries, API keys, or video playback.

1. What “one-shot” means

A one-shot classification task provides one labeled support example for each candidate class, then asks for the label of a new query. A three-way, one-shot task has three support examples total. “One-shot” does not mean that a complete intelligent system is trained from scratch on one document, or that an installer runs once.

ConceptWhat changes?Here
One-shot inferenceA support example defines a new class prototype.Fixed token-count vectors and cosine similarity.
Few-shot meta-learningAn encoder or learning rule is trained across many tasks.Explained below; expensive neural training is not installed.
Model trainingNumerical parameters are fitted from data.Small next-word bigram counts and conditional probabilities.
RetrievalSources are searched and returned as evidence.Private SQLite text collection with source URLs.
LLM inferenceA provider generates text using an already-trained model.Optional, explicitly configured free-project API; disabled initially.

A strong pretrained representation often matters more than the single example itself. Our inexpensive lexical representation understands shared words, not synonyms, negation, or reasoning. “Optimize weights” can fail to match “learn parameters” despite their related meanings.

2. A complete three-way, one-shot experiment

Edit one support example per class and enter a query. All computation happens in your browser. Nothing is sent to the server or an AI provider. The initial data below is original synthetic teaching data, not a benchmark.

Show every step and the teaching dataset

1. Lowercase; retain alphabetic tokens of length 2–24 (maximum 4,000 tokens). 2. Count each token. 3. Divide counts by their Euclidean norm. 4. Compute each dot product. 5. Convert to squared distance and relative softmax score. 6. Abstain if the best cosine is below 0.1 or its margin over second place is below 0.05. These thresholds are illustrative, not calibrated.

support = [
 {label: "retrieval", text: "retrieve documents search sources evidence knowledge context citations"},
 {label: "training", text: "train model weights gradient optimization loss learning examples"},
 {label: "evaluation", text: "evaluate model accuracy test benchmark heldout metrics performance"}
]
queries = [
 {text: "retrieve documents search", expected: "retrieval"},
 {text: "train model weights", expected: "training"},
 {text: "evaluate test accuracy", expected: "evaluation"},
 {text: "bananas ocean bicycle", expected: "uncertain"}
]

These easy examples test the implementation. They do not establish useful real-world accuracy.

3. Mathematical derivations

Notation and prototypes

Let the support set be S = {(xᵢ, yᵢ)}, with N classes and K examples per class. Let z = f(x) ∈ ℝᵈ represent an input. The prototype cₖ is the mean representation of class k:

cₖ = (1 / |Sₖ|) Σᵢ:yᵢ=k f(xᵢ)
One-shot: |Sₖ| = 1, so cₖ = f(xₖ).

Why the mean? For a squared-distance objective J(c) = Σᵢ ‖zᵢ − c‖², differentiate and set the derivative to zero:

∇c J(c) = 2 Σᵢ (c − zᵢ) = 2n c − 2 Σᵢ zᵢ = 0
⇒ c* = (1/n) Σᵢ zᵢ.
The Hessian is 2nI, positive definite for n > 0.

This is the geometric basis of a prototype classifier. Learned prototypical networks train the representation; this demo fixes it. Snell, Swersky & Zemel, 2017.

Cosine similarity and a worked calculation

Let vⱼ(x) count token j and z = v/‖v‖₂. For two nonempty normalized vectors, squared Euclidean distance and cosine similarity give the same ordering:

‖z − c‖² = zᵀz + cᵀc − 2zᵀc = 2 − 2 cos(z,c).
Choose class k* = argminₖ ‖z − cₖ‖² = argmaxₖ zᵀcₖ.

For a support example “search sources” and query “search,” the vectors in vocabulary order (search, sources) are c = (1/√2, 1/√2) and z = (1,0). Their cosine is 1/√2 ≈ 0.7071 and squared distance is 2 − √2 ≈ 0.5858. A disjoint support vector has cosine 0 and distance 2. Sparse dictionaries avoid storing thousands of zero entries.

From distances to relative scores

p(k | x,S) = exp(−dₖ/τ) / Σⱼ exp(−dⱼ/τ), τ > 0.
L = −log p(y | x,S) = dᵧ/τ + log Σⱼ exp(−dⱼ/τ).
∂L/∂dₖ = (1[k=y] − p(k | x,S)) / τ.

For gradient descent, the correct class distance is pushed down and other class distances up. If dₖ = ‖z − cₖ‖², then ∂dₖ/∂z = 2(z − cₖ). Backpropagation can train an encoder with these derivatives. Our demo performs no such encoder training. Temperature τ = 0.25 controls how peaked the displayed scores are; it does not make them reliable probabilities.

Matching networks: attend to examples

a(x,xᵢ) = softmaxᵢ(cos(f(x),g(xᵢ)))
p(y | x,S) = Σᵢ a(x,xᵢ) · 1[yᵢ = y].

Instead of averaging examples into class prototypes, this approach combines the labels of individual support examples using learned similarity. See Vinyals et al., Matching Networks. Our single-example-per-class demonstration uses a simpler fixed representation.

Optimization-based adaptation (MAML)

Inner update for task T:
  θ′T = θ − α ∇θ Lsupport,T(θ)
Meta-objective:
  J(θ) = ΣT Lquery,T(θ′T)
Chain rule for one inner step:
  ∇θ J = ΣT [I − α Hsupport,T(θ)]ᵀ ∇θ′ Lquery,T(θ′T)
Outer update:
  θ ← θ − β ∇θ J.

H is the support-loss Hessian. The outer update chooses an initialization that adapts quickly to new tasks. First-order approximations omit the Hessian term. This requires many training tasks; one support example at evaluation is not the full training budget. MAML is educational material here, not a workload launched on JustHost. Finn, Abbeel & Levine, 2017.

What a valid experiment measures

Keep support and query samples distinct. For meta-learning, split training, validation and test classes/tasks before constructing episodes. Deduplicate sources and keep documents from the same origin together when possible. Tune thresholds on validation tasks only. Report task construction, N, K, representation, query count, accuracy, abstention rate and compute budget. A toy demo with repeated phrases cannot measure general intelligence.

accuracy = correct accepted predictions / all test queries
coverage = accepted predictions / all test queries
selective accuracy = correct accepted predictions / accepted predictions
Approximate standard error for independent binary outcomes:
  SE ≈ √[p̂(1−p̂)/m].
Correlated queries require episode-level uncertainty analysis instead.

4. What each code file does

Allowed sources → robots and budget checks → private SQLite → small model + evaluation → authenticated research view

FileResponsibility
install-ai.shEmbedded, checksum-verified software payload; runtime creation; tests; private account setup; website publication; saved checks.
launch-ai.shSingle-job lock, account inode guard, wall timeout, CLI dispatch and logs. No daemon.
core.pyAllowlisted crawler, persistent reservations, source database, lexical retrieval, bigram fitting/evaluation, optional API call.
one_shot.pyOne-example-per-class cosine classifier with abstention.
auth.php / admin.phpPassword hashing, account creation, rate limits, additive SQLite schema.
site.phpHTTPS login, CSRF, session rotation/expiry, mandatory initial password change, read-only source search and metrics.
guide.html / demo.jsThis offline-capable explanation and local-browser teaching experiment.
selftest.py / auth-test.phpRepeatable checks without network usage or provider spending.

Only the public wrappers, styles and guide go into the website folder. Credentials, databases, model files and job logs remain outside the document root. The owner can queue bounded jobs; web users cannot execute arbitrary commands or incur API charges.

5. Recreate the environment with one Bash program

Sign in to the hosting account over SSH as leephdco. Use the saved PuTTY session or your preferred SSH client. The account password is never embedded in the installer.

cd /home1/leephdco/DEVEL/AI
bash install-ai.sh

This checks Linux ownership, Python 3.8+, PHP 8.1+ with PDO SQLite, file usage, space and required tools. It creates an isolated standard-library Python environment without downloading third-party packages. It preserves existing users, source data, budget counters and configuration. No root access is needed.

To replace the Python runtime as well, using the same software bundle:

bash /home1/leephdco/DEVEL/AI/install-ai.sh --rebuild

“Afresh” means rebuilding software, not erasing research or accounts. The installer does not download moving “latest” dependencies; the embedded release is reproducible. Restore from this installer on the same account and paths. It is not a backup of your subsequently collected data. Keep encrypted data backups on your own computer, consistent with the hosting policy.

DNS, a valid HTTPS certificate, hosting ownership and a free SSH login slot are provider prerequisites. The script checks what it can and stops on failure; it cannot purchase a domain, issue unavailable permissions, or raise hosting quotas.

First login

cat /home1/leephdco/DEVEL/AI/private/initial-login.txt

Read this only in your private terminal. Visit the login page, use the generated owner account, and set a new unique password. The initial credential file is removed after the owner changes the password. Reinstallation does not reset existing passwords.

6. Web controls and commands for daily use

The signed-in interface uses a sidebar and research conversation. Send a question to retrieve cited passages from the local corpus. This is transparent source search, not a simulated LLM response. The last 20 exchanges are stored privately per user. No API key or external AI call is used by the chat page. The browser guide demo remains an independent client-side experiment.

Sign in as the owner to queue Collect + train, Train existing data, Run diagnostics or One-shot check. Refresh the dashboard to inspect status, exit code and saved output. Jobs run through a bounded worker, not inside web requests. Other registered users can search sources and view metrics; only the owner controls the shared job budget. Guests cannot access the research database or queue jobs.

# Collect up to six due pages, then fit/evaluate the small model:
bash /home1/leephdco/DEVEL/AI/launch-ai.sh run

# Train from existing sources without crawling:
bash /home1/leephdco/DEVEL/AI/launch-ai.sh train

# Inspect document count and persisted reservations:
bash /home1/leephdco/DEVEL/AI/launch-ai.sh status

# Source lookup without a paid or external AI request:
bash /home1/leephdco/DEVEL/AI/launch-ai.sh search 'model evaluation'

# One-shot demo using editable support examples:
bash /home1/leephdco/DEVEL/AI/launch-ai.sh one-shot 'train model weights'

# Optional generation; returns local search while provider is disabled:
bash /home1/leephdco/DEVEL/AI/launch-ai.sh ask 'How should I evaluate a small model?'

# Create another login; the password prompt does not echo:
bash /home1/leephdco/DEVEL/AI/launch-ai.sh add-user researcher

# Reset an account if its user forgets the password:
bash /home1/leephdco/DEVEL/AI/launch-ai.sh reset-password researcher

Change scope and quotas in /home1/leephdco/DEVEL/AI/config.json. Change one-shot support examples in support.json. Use the provided schema and keep one distinct label per example. The defaults collect official Python/scikit-learn reference pages, one-shot research abstracts on arXiv, and the Stanford CS330 course page. The crawler fetches the specified URLs only; it does not enumerate search engines or follow arbitrary links. Add an approved HTTPS host and a precise source URL to expand scope. Respect source terms and copyright; robots.txt permission is not a content license.

The installer configures a five-minute queue worker and a separate six-hour bounded learning schedule, preserving other cron entries. An empty queue does not crawl or train through that worker. A separate six-hour scheduler now alternates general and legal research; see the law guide for its resource controls. There can be at most three pending jobs and 24 submissions per rolling day. Reinstallation does not duplicate the cron entry. Do not run competing copies under different installation directories.

7. The trained model and its checks

The workspace fits a statistical bigram language model, not a transformer. It counts how often one token follows another, then uses add-one smoothing. The fitted counts are model parameters; no gradient descent or GPU is required.

C(a,b) = number of times token b follows token a in training documents
C(a) = Σb C(a,b)
P(b | a) = [C(a,b) + 1] / [C(a) + |V|]
NLL = −(1/M) Σt log P(wt | wt−1)
perplexity = exp(NLL).

Probabilities sum to one because Σb[C(a,b)+1] = C(a)+|V|. Add-one smoothing assigns positive probability to unseen transitions. The vocabulary contains at most 1,500 frequent training tokens plus <unk>. Only training documents build that vocabulary. Each source contributes at most 4,000 tokens. Training requires at least five unique documents; every fifth document in a stable content-hash ordering is held out. With six documents, four train and two test. Document changes can change the split, so compare runs cautiously.

The saved report includes training/test counts, held-out token count, vocabulary size, model perplexity, and a unigram baseline evaluated on the same tokens. Lower perplexity is better only when comparing the same held-out data and vocabulary. This model can be worse than the simpler baseline. It is not automatically promoted as a production language model.

data/model.json       fitted vocabulary, counts, context totals and timestamp
data/training.json    evaluation metrics or explicit reason for skipping
data/status.json      most recent completed collection/training summary
logs/job-*.log        job output and exit code
logs/checks-*.tsv     installer checks with UTC timestamp and PASS/FAIL

The one-shot demo and the bigram model are separate experiments. To develop a stronger one-shot system later, collect properly licensed labeled tasks, choose a compact pretrained embedding model on a suitable external compute environment, and evaluate disjoint tasks. This installer does not pretend that web crawling alone produces a general one-shot AI core.

8. Resource and free-API boundaries

Local defaultLimit
Worker virtual-address space192 MiB, or a lower inherited OS limit
Worker CPU / elapsed time15 CPU seconds / 90-second alarm; outer 100-second timeout
Crawl requests24/day, including robots.txt and failures
Reserved response bytes8 MiB/day, 64 MiB/month; at most 512 KiB/response
Stored sources100 documents; 24,000 characters per source; 64 MiB data guard
Refresh and concurrencyAt least 7 days per source by default, 3 seconds between requests, one worker
Account file guardPause at 180,000 files/directories; provider policy identifies over 200,000 inodes as potentially excessive

These are application safety caps, not an official JustHost RAM entitlement or a guarantee that other applications stay within the account quota. Header/TLS overhead and other account traffic are outside the application's response-byte budget. Existing website usage still counts at the host. Shared-server total memory/free disk is not your personal allocation.

Optional free inference

The core works with zero API keys. Gemini API free access is project/model dependent and changes over time; inspect your project's current limits in AI Studio. Use an unbilled project and verify the selected model is free. Website subscriptions and interactive chat allowances are not assumed to be API credits. No cookie scraping, quota rotation, account farming or paid fallback is implemented.

  1. Review current project rate limits, model pricing, and data-use terms.
  2. Privately write the authorized API key into private/gemini.key and set mode 600. Never put it into the web folder, support examples or shell command history.
  3. In config.json, choose the verified model, set confirmed_free_project and enabled to true, and set conservative nonzero day/month request caps below your available allowance.
  4. Invoke launch-ai.sh ask deliberately. It sends the query and public-source excerpts to that provider. Do not include personal or confidential material.

The adapter allows at most 10 calls/day, 100/month, 6,000 input characters/request and 256 output tokens/request. It stops on HTTP errors including 429 without retries or provider switching. These caps cannot make a billed project free; the disabled default is the only zero-provider-spend guarantee. API inference does not train your local model and does not modify the provider's model weights.

9. Data provenance and reproducibility

Every collected document stores its URL, title, bounded extracted text, retrieval timestamp and SHA-256 of the stored text. Hashes detect exact duplicates of retained text, not semantic duplicates. Scripts/styles are discarded. The corpus stays private behind login; public pages show only original teaching material and links. Raw collected text is never interpreted as code or instructions.

The self-tests generate temporary synthetic data and remove it afterward. They test behavior, not research performance. The provided support examples are original teaching data and may be adapted freely. External source text remains subject to its owners' terms; links here do not imply permission to redistribute full articles or lectures. No large dataset, copyrighted lecture video, model weights or provider credentials are bundled.

AI/
  config.json, support.json, episodes.json    persistent settings and examples
  runtime/                    isolated Python interpreter environment
  current → releases/HASH/    verified application code and guide source
  private/                    account DB, sessions, optional key
  data/                       knowledge DB, usage counters, model, metrics
  logs/                       saved installation and job checks
  launch-ai.sh                bounded entry point

For reproducible reports, retain the installer checksum, source hashes, support set, query set, configuration and metrics. Do not include passwords or API keys in shared experiment records. Re-running setup alone will not recreate a deleted corpus; re-collection depends on current source availability.

10. Troubleshooting and recovery

SSH says “too many logins”

Log out of unused SSH sessions normally. Do not kill unknown sessions. The installer cannot override the hosting login cap.

Required PHP, Python or SQLite feature is missing

Read the exact FAIL check. Ask JustHost to enable the account-supported runtime/module. Do not install system packages or silently switch databases. The script stops before website activation.

Training skipped / no documents collected

Read status.json and the job log. Fewer than five unique documents, robots exclusions, rejected redirects, unreachable sources, response-size limits, or spent budgets are reported. Fix scope or wait for quota reset; do not bypass source restrictions.

CPU, memory, inode or wall-time cap reached

The job exits nonzero and the outer log records its exit. Already committed documents remain. Partial model output is written to a temporary file and only promoted atomically when complete. Reduce collection scope or move substantial training to appropriately allocated compute.

Forgotten password / too many attempts

Wait 15 minutes after login throttling. The account owner can run the reset-password command over SSH. Resetting increments the account version and invalidates existing sessions. Password recovery does not send email or expose credentials publicly.

Website HTTPS or private-path check fails

Confirm DNS and the certificate for www.iicsm.org. The installer reports failure and restores the prior application release pointer when available. Existing files in an unmanaged /ai directory are never overwritten. The older institute website remains outside /ai.

Repeat setup vs destructive reset

Use the same installer, optionally with --rebuild. It preserves research and accounts. There is no wipe-all flag. Before any intentional data reset, export and verify an encrypted offline backup and understand that the usage counters must not be cleared to evade daily/monthly limits.

Additional tools: retrieval, evaluation and dataset review

These tools run on the account's CPU, with no third-party packages, model downloads or API calls. They share the configured memory, CPU, wall-time and data caps. The private workspace has owner buttons for Evaluate one-shot, Audit corpus and Export dataset. Jobs run through the same serialized queue and save their output. Every registered user can inspect the resulting reports; exported source text remains outside the public web directory.

BM25: better evidence retrieval

Chat and command-line search now rank documents using BM25. Let N be the document count, df(t) the number containing term t, f(t,d) its frequency in document d, L the document's token count and A the average document length. With k₁ = 1.2 and b = 0.75, the implemented score is:

IDF(t) = ln[1 + (N − df(t) + 0.5)/(df(t) + 0.5)]
score(d,q) = Σ(t in q) IDF(t) · f(t,d)(k₁+1)
                          / [f(t,d) + k₁(1 − b + bL/A)]

The log ratio gives rarer terms more weight. The frequency fraction saturates: repeating a term indefinitely approaches k₁+1 instead of increasing without bound. Length normalization reduces the advantage of long documents. For L=A and f=1, the fraction is exactly 1. This is a practical BM25 variant, not semantic understanding. English alphabetic tokens of length 3–24 are used; query stop words are removed, and up to 12 unique terms and 100 documents are considered. No matching token means no answer. Cited excerpts remain untrusted source material.

Read the original probabilistic retrieval account in Robertson and Zaragoza, The Probabilistic Relevance Framework: BM25 and Beyond (2009). This implementation uses a positive IDF smoothing variant; it does not reproduce all relevance-feedback or field-weighting variants.

One-shot evaluation with separate support and query examples

Edit episodes.json, a JSON object mapping 2–20 class names to 2–20 distinct example strings per class. The bundled nine examples are original teaching sentences for retrieval, training and evaluation. Each episode takes exactly one example per class as support and evaluates the remaining examples. The support index rotates up to the smallest class size. Duplicate normalized examples are rejected across the whole pool. No query is its own support inside an episode. Examples rotate between roles across episodes, so the reported decisions are correlated. Keep a separate untouched test dataset before claiming generalization, and do not tune on these scores.

{
  "retrieval": ["retrieve documents using source search", "search source documents for relevant evidence"],
  "training": ["train model weights with gradient optimization", "optimize model weights during training"]
}

Let T be all query decisions, C the correct predictions and K the non-abstained predictions. Accuracy = C/T; coverage = K/T; selective accuracy = C/K (undefined when K=0). An abstention counts as incorrect for overall accuracy. For class c, F1(c) = 2TP/(2TP+FP+FN), including abstentions in FN. Macro F1 averages classes equally. The report includes a confusion matrix and query SHA-256 values for tracing decisions without duplicating query text. Relative one-shot scores are not calibrated probabilities. See the scikit-learn metric definitions; scikit-learn is a reference, not an installed dependency.

Corpus quality and source provenance

The audit recomputes stored text hashes, groups exact duplicates, and flags pairs whose token-set Jaccard similarity J(A,B)=|A∩B|/|A∪B| is at least 0.85. It also flags documents shorter than 50 tokens and a few instruction-like phrases for human review. These heuristic flags do not certify safety, originality or truth, and similar vocabulary need not mean duplicated meaning. Nothing is deleted automatically. Inspect flagged URLs before changing seeds or using data for an experiment.

Dataset export writes one JSON record per source into private data/dataset.jsonl: URL, title, extracted body, retrieval timestamp, stored-text SHA-256 and an explicit unverified-license status. The manifest data/export.json records file size and SHA-256. Export checks available local data quota before atomic replacement and includes neither passwords nor conversations. Fetch permission and robots permission do not establish a redistribution or model-training license. Review the original terms before reusing or sharing an export.

Run and inspect

cd /home1/leephdco/DEVEL/AI
bash launch-ai.sh search 'one shot prototype learning'
bash launch-ai.sh evaluate
bash launch-ai.sh audit
bash launch-ai.sh export
cat data/evaluate.json
cat data/audit.json
cat data/export.json
# Read the source dataset privately; it is not publicly downloadable:
head -n 1 data/dataset.jsonl

The installer preserves edited episodes.json, support examples, accounts, existing research, budgets and reports. To recreate program files and runtime, run bash install-ai.sh --rebuild. Then rerun the three research commands to regenerate reports from the current private data. Every action prints results and saves a timestamped job log. The dashboard shows reports and bounded job output; it does not provide an unrestricted terminal.

11. Papers, lectures and reference materials

Start with the original explanations above, run the toy experiment, then use these primary materials for depth. The guide is not dependent on these links loading, but full external courses and papers are not reproduced here.

  1. Snell, Swersky & Zemel (2017), Prototypical Networks for Few-shot Learning — prototype geometry and learned representations.
  2. Vinyals et al. (2016), Matching Networks for One Shot Learning — attention over a labeled support set.
  3. Finn, Abbeel & Levine (2017), Model-Agnostic Meta-Learning — inner and outer optimization.
  4. Stanford CS330: Deep Multi-Task and Meta Learning — course, reading sequence and assignments.
  5. Stanford Online, CS330 2022 Lecture 6: Non-Parametric Few-Shot Learning — video lecture; companion slides.
  6. Stanford CS330, Optimization-Based Meta-Learning slides — MAML derivation and tradeoffs.
  7. scikit-learn evaluation guide — measurement and model selection.
  8. Python robots parser, SQLite, and resource limits — runtime references.
  9. JustHost resource policy, section 17 and acceptable-use policy — authoritative hosting rules.
  10. Gemini billing, rate limits, and pricing — verify before enabling external inference.

A suggested study sequence

Session 1: vectors, dot products and the browser demo. Session 2: derive prototype means and softmax gradients by hand. Session 3: watch the metric-learning lecture, then create a disjoint support/query set. Session 4: run collection and inspect provenance and perplexity. Session 5: read MAML and design a future experiment without launching expensive training on shared hosting.

Law research and automatic learning

Open the law workspace for California/US business and contract sources. Read the law and provider guide for API configuration and periodic learning controls. Generated drafts remain separate from primary sources and are not automatically used as training data.