OpenAI logo

CLIP

CLIPv1Current
byOpenAIOpenAI(ai lab)
Released January 5, 2021
Context--
CategoryVision Model

About CLIP

CLIP is OpenAI’s Contrastive Language-Image Pretraining model family, trained to connect images and natural-language text so it can perform zero-shot image classification and image-text retrieval.

Capabilities

visiontextzero shot classificationimage text retrieval

Input Modalities

imagetext

Output Modalities

embeddingssimilarity-scores

Technical Details

API Identifier
openai/clip
Category
Vision Model

Tags

vision-languageopenaizero-shotimage-classificationmultimodalretrieval

Run this model yourself

Local and cloud setup for CLIP, with exact configurations, sources and clear evidence limits.

Find a model for your hardware
Local hardwareDocumented setupSources checked Oct 16, 2026

Compare fixed CLIP image/text inputs on a research CPU desktop

Reproduce a private, fixed-input ViT-B/32 research check with OpenAI’s native CLIP code, checkpoint, BPE vocabulary and publisher diagram fixture. Compare three fixed English labels through normalized 512-dimensional embeddings and similarity logits. The native text limit is 77 tokens per label, including start/end tokens. This educational loopback prototype is not a production service or calibrated classifier; publisher model card places any deployed use outside scope. Fit and performance are unmeasured.

Hardware
Intel Core i5-12400 desktop, 4 inference threads, 32 GiB RAM
Runtime
Native OpenAI CLIP CPU paired-input private research wrapper OpenAI CLIP d05afc436d78f1c48dc0dbf8e5980a9d471f35f6; torch 2.6.0+cpu; torchvision 0.21.0+cpu; Python 3.12 · CPU
Model format
PyTorch JIT checkpoint · Native CPU float32 eager model loaded with jit=False · No quantization; native eager CPU load converts model to float32
Workload
77 token context · 1 concurrent

Based on source documentation; this setup has not been executed by OpenTools. Memory: unknown. No compatible measurement available.

Read the complete setup guide

Before you start

  • Use an owned Intel Core i5-12400 desktop with Ubuntu 24.04 x86_64, 32 GiB installed RAM and 40 GiB free disk. Allocate four inference threads and build natively on the same host.
  • Experimental private research only. The native model card places any deployed use outside scope; this educational loopback wrapper is a reproducible test harness, not production-safe hosting or a calibrated classifier. Do not use scores for automatic or consequential decisions.
  • Use only the exact publisher architecture diagram fixture and fixed English labels a diagram / a dog / a cat. No uploads, arbitrary URLs or user-defined taxonomy are accepted. Confirm the intended use and retain MIT notices.
  • 32 GiB RAM, 40 GiB disk and four threads are planning allocations, not measured fit. The chosen ViT-B/32 is one of nine native released variants; the other eight and broader workflows remain unqualified.

Exact model and requirements

Artifact:
OpenAI / CLIP ViT-B/32 native checkpoint (representative family variant) · checkpoint openai/CLIP ViT-B/32
Publisher revision:
d05afc436d78f1c48dc0dbf8e5980a9d471f35f6
Artifact digest:
sha256:40d365715913c9da98579312b702a82c18be219cc2a73407c4526f58eba950af
Download size:
0.33 GiB
Memory requirement (unknown):
Unknown — No exact full-process peak for native CLIP ViT-B/32 CPU float32, image/text encoders, preprocessing and wrapper.
System RAM / disk:
Unknown / Unknown
Placement:
single device. One CPU host; no tensor/pipeline sharding. Entire model on CPU; no device_map, GPU or disk offload.
KV cache:
Non-autoregressive paired encoders; no chat/generation K/V cache is configured.
Workload:
77 token context; Unknown; Not applicable; concurrency 1; batch 1; cache unknown; repetitions Unknown.
Tokenizer:
Native CLIP SimpleTokenizer and exact bpe_simple_vocab_16e6.txt.gz · d05afc436d78f1c48dc0dbf8e5980a9d471f35f6
Sampling / reasoning:
No text sampling. Three fixed labels: a diagram, a dog, a cat; fixed publisher CLIP.png. Native resize/center crop to 224 RGB and normalization; image batch 1, text batch 3 padded to 77. No silent truncation. No chat, reasoning, instruction template, text generation or tool execution. Embeddings are normalized before cosine similarity; logits use native learned logit_scale. Relative label scores are not calibrated probabilities or universal truth.
Runtime prerequisites:
Ubuntu 24.04 x86_64; See prerequisites above.

Official artifact · License

Native OpenAI CLIP repository MIT license and OpenAI-owned ViT-B/32 card MIT declaration are archived; retain copyright/license notices. Native model card recommends research and identifies any deployed use as out of scope. This fixed-input private educational experiment does not establish deployment suitability, safety, fairness, calibration or legal clearance. Inputs/labels are English; no automatic decisions or consequential classification.

  • 353,976,522 bytes is publisher expected checkpoint content length from HEAD metadata, not a downloaded weight-body measurement or full runtime RAM requirement.
  • 32 GiB RAM, 40 GiB disk and four threads are author planning allocations, not measured minima. Both encoders, preprocessing, buffers, dependencies and OS add memory/storage.

One-time setup and hardware

hardware
Unknown — Existing desktop purchase price and incremental hardware cost depend on the reader; unknown.
Existing desktop purchase price and incremental hardware cost depend on the reader; unknown. Tax: unknown.
setup
Unknown — Initial provisioning/build time and labor cost are unknown.
Initial provisioning/build time and labor cost are unknown. Tax: unknown.

Recurring costs

electricity
Unknown — Actual wall power, electricity rate and powered hours are unknown; no TDP-to-wall-power conversion.
Actual wall power, electricity rate and powered hours are unknown; no TDP-to-wall-power conversion. Tax: unknown.
storage
Unknown — Incremental cost of local disk capacity is unknown. The 40 GiB free-disk walkthrough allocation is an author choice, not a measured requirement.
Incremental cost of local disk capacity is unknown. The 40 GiB free-disk walkthrough allocation is an author choice, not a measured requirement. Tax: unknown.
egress
Unknown — Data transfer price, allowances and traffic volume are unknown.
Data transfer price, allowances and traffic volume are unknown. Tax: unknown.
administration
Unknown — Maintenance labor rate and hours are unknown.
Maintenance labor rate and hours are unknown. Tax: unknown.

Install the runtime

  1. 1. Create the pinned CPU research environment

    Install hashed official CPU wheels and exact native CLIP source. CLIP dependencies/transitive packages resolve at installation; save pip freeze and stop on pip check errors. This is documented compatibility, not an executed environment.

    Command
    sudo apt-get update
    sudo apt-get install -y python3.12 python3.12-venv git curl ca-certificates openssl
    mkdir -p "$HOME/clip-research/models" "$HOME/clip-research/fixture"
    cd "$HOME/clip-research"
    python3.12 -m venv .venv
    .venv/bin/python -m pip install "https://download.pytorch.org/whl/cpu/torch-2.6.0%2Bcpu-cp312-cp312-linux_x86_64.whl#sha256=59e78aa0c690f70734e42670036d6b541930b8eabbaa18d94e090abf14cc4d91" "https://download-r2.pytorch.org/whl/cpu/torchvision-0.21.0%2Bcpu-cp312-cp312-linux_x86_64.whl#sha256=d6874431e678ba107b60a83f255c33f3755f06bad587b1b919aa514ec325dcd8"
    git clone https://github.com/openai/CLIP.git native-clip
    git -C native-clip checkout --detach d05afc436d78f1c48dc0dbf8e5980a9d471f35f6
    .venv/bin/python -m pip install ./native-clip
    .venv/bin/python -m pip check
    .venv/bin/python -m pip freeze > resolved-environment.txt

    Expected result: Exact checkout and CPU wheel hashes resolve; pip check passes and actual environment is recorded. No GPU driver required.

Download the model

  1. 1. Verify checkpoint, native tokenizer vocabulary and fixed fixture

    Only the reader following this guide downloads the weight body. The publisher URL contains the expected SHA-256 and archived HEAD reports 353,976,522 bytes; this author did not download it. Verify every selected input before load.

    Command
    cd "$HOME/clip-research"
    curl --fail --location --output models/ViT-B-32.pt 'https://openaipublic.azureedge.net/clip/models/40d365715913c9da98579312b702a82c18be219cc2a73407c4526f58eba950af/ViT-B-32.pt'
    curl --fail --location --output fixture/CLIP.png 'https://raw.githubusercontent.com/openai/CLIP/d05afc436d78f1c48dc0dbf8e5980a9d471f35f6/CLIP.png'
    sha256sum --check <<'SHA256'
    40d365715913c9da98579312b702a82c18be219cc2a73407c4526f58eba950af  models/ViT-B-32.pt
    308a3ca4503f1c7a07803916c369d78c4ef501e5ab7fc727da9b5e1d2f9ec85b  fixture/CLIP.png
    924691ac288e54409236115652ad4aa250f48203de50a9e4722a6ecd48d6804a  native-clip/clip/bpe_simple_vocab_16e6.txt.gz
    SHA256

    Expected result: All three expected hashes report OK. Stop on mismatch. Only trusted publisher checkpoint is used; no arbitrary PyTorch file input.

Configure

  1. 1. Create a private research key

    Create a local service key only when absent; preserve existing access and do not print or share it. This is not a provider API key.

    Command
    cd "$HOME/clip-research"
    umask 077
    if [ ! -e .api-key ]; then openssl rand -hex 32 > .api-key; fi
    test -s .api-key || { echo "Restore empty key before continuing"; exit 1; }
    chmod 600 .api-key

    Expected result: Private nonempty .api-key exists; existing key preserved.

  2. 2. Create the fixed-input research harness

    Reader-authored serial HTTPServer binds loopback and accepts only a fixed fixture identifier. It provides no production service guarantees. It loads the exact local image/model and fixed labels; it does not fetch URLs or accept uploads.

    Command
    cd "$HOME/clip-research"
    cat > clip_research.py <<'PYSERVER'
    """OpenTools reader-authored educational demonstrator; not publisher server."""
    import hmac,json,os
    from http.server import BaseHTTPRequestHandler,HTTPServer
    
    def handler_factory(generate,key):
        class Handler(BaseHTTPRequestHandler):
            protocol_version='HTTP/1.0'
            def setup(self):
                super().setup(); self.connection.settimeout(10)
            def log_message(self,*args): pass
            def reply(self,status,data):
                body=json.dumps(data,ensure_ascii=False).encode()
                self.send_response(status); self.send_header('Content-Type','application/json; charset=utf-8')
                self.send_header('Content-Length',str(len(body))); self.end_headers(); self.wfile.write(body)
            def authorized(self):
                value=self.headers.get('Authorization','').encode()
                return hmac.compare_digest(value,('Bearer '+key).encode())
            def do_GET(self):
                if not self.authorized(): return self.reply(401,{'error':'unauthorized'})
                if self.path!='/health': return self.reply(404,{'error':'not_found'})
                self.reply(200,{'status':'ready'})
            def do_POST(self):
                if not self.authorized(): return self.reply(401,{'error':'unauthorized'})
                if self.path!='/v1/clip-research': return self.reply(404,{'error':'not_found'})
                if self.headers.get('Transfer-Encoding') is not None: return self.reply(400,{'error':'transfer_encoding_unsupported'})
                if self.headers.get_content_type()!='application/json': return self.reply(415,{'error':'json_required'})
                lengths=self.headers.get_all('Content-Length',[])
                if len(lengths)!=1 or not lengths[0] or not all('0'<=c<='9' for c in lengths[0]): return self.reply(411,{'error':'content_length_required'})
                if len(lengths[0])>4: return self.reply(413,{'error':'body_limit'})
                n=int(lengths[0])
                if not 1<=n<=1024: return self.reply(413,{'error':'body_limit'})
                try:
                    raw=self.rfile.read(n)
                    if len(raw)!=n: return self.reply(400,{'error':'incomplete_body'})
                    data=json.loads(raw)
                except (ValueError,UnicodeError,TimeoutError): return self.reply(400,{'error':'invalid_json'})
                if type(data)!=dict or data!={'fixture':'publisher-clip-diagram'}:
                    return self.reply(400,{'error':'fixed_fixture_required'})
                try: result=generate()
                except Exception: return self.reply(500,{'error':'generation_failed'})
                self.reply(200,result)
        return Handler
    
    def main():
        import torch,clip
        from PIL import Image
        from clip.simple_tokenizer import SimpleTokenizer
        key=open('.api-key',encoding='ascii').read().strip()
        if len(key)!=64 or any(c not in '0123456789abcdef' for c in key): raise SystemExit('Invalid service key')
        torch.set_num_threads(4)
        model,preprocess=clip.load('models/ViT-B-32.pt',device='cpu',jit=False)
        model.eval()
        labels=['a diagram','a dog','a cat']
        tokenizer=SimpleTokenizer()
        counts=[len(tokenizer.encode(x))+2 for x in labels]
        assert all(2<=n<=77 for n in counts)
        tokens=clip.tokenize(labels,context_length=77,truncate=False)
        assert list(tokens.shape)==[3,77]
        with Image.open('fixture/CLIP.png') as im:
            assert im.size==(2162,762)
            image=preprocess(im.convert('RGB')).unsqueeze(0)
        assert list(image.shape)==[1,3,224,224]
        def generate():
            with torch.inference_mode():
                i=model.encode_image(image).float()
                t=model.encode_text(tokens).float()
                assert list(i.shape)==[1,512] and list(t.shape)==[3,512]
                i=i/i.norm(dim=-1,keepdim=True)
                t=t/t.norm(dim=-1,keepdim=True)
                cosine=i@t.T
                logits=model.logit_scale.exp()*cosine
                assert torch.isfinite(cosine).all() and torch.isfinite(logits).all()
            return {'scope':'private research only; deployed use is outside publisher scope','fixture':'publisher-clip-diagram','labels':labels,'text_tokens_including_bos_eos':counts,'padded_text_shape':[3,77],'image_shape':[1,3,224,224],'image_embedding_shape':[1,512],'text_embedding_shape':[3,512],'cosine':cosine[0].tolist(),'logits':logits[0].tolist(),'highest_label':labels[int(logits[0].argmax())],'calibrated':False}
        HTTPServer(('127.0.0.1',8996),handler_factory(generate,key)).serve_forever()
    if __name__=='__main__': main()
    PYSERVER
    .venv/bin/python -m py_compile clip_research.py

    Expected result: Python syntax check passes without loading the model.

Start the model

  1. 1. Start the private fixed-input experiment

    In a foreground terminal, load native eager CPU float32 with four threads. Startup verifies input shapes and native text length per fixed label. One request at a time; no public listener, batching service or automatic decisions.

    Command
    cd "$HOME/clip-research"
    .venv/bin/python clip_research.py

    Expected result: After source-supported but unexecuted load, authenticated health can report ready. Stop on missing input, token overflow or preprocessing assertion.

Connect to your endpoint

http://127.0.0.1:8996/v1/clip-research

Same trusted research desktop loopback only.

Access: loopback. Private Bearer key required for health and research request. Exact JSON body fixture=publisher-clip-diagram only. No image uploads, arbitrary URLs, prompts or new labels. This is a reader-authored experimental harness, not publisher deployment guidance.

Verify the setup

  1. 1. Inspect paired-input research output

    Run from a second terminal on the server. Confirm exact fixed labels, token counts <=77 including start/end, padded text shape 3x77, image 1x3x224x224, embedding shapes 1x512 and 3x512, and three finite cosine/logit values. The source fixture is an architecture diagram containing dog photographs; inspect this taxonomy limitation yourself. Ranking must be internally consistent with reported logits, but no exact ranking or number is promised. A shape/finite smoke check is not in-domain quality, calibration, bias or deployment validation.

    Command
    cd "$HOME/clip-research"
    CLIP_RESEARCH_KEY="$(cat .api-key)"
    curl --fail http://127.0.0.1:8996/health -H "Authorization: Bearer $CLIP_RESEARCH_KEY"
    curl --fail http://127.0.0.1:8996/v1/clip-research -H "Authorization: Bearer $CLIP_RESEARCH_KEY" -H 'Content-Type: application/json' -d '{"fixture":"publisher-clip-diagram"}'
    curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8996/health
    unset CLIP_RESEARCH_KEY

    Expected result: Authorized health ready; research JSON contains shapes, per-label counts, finite cosine/logits and highest_label derived from those logits, calibrated=false. Missing key returns 401. No actual model result is claimed.

Performance evidence

No compatible measurement available. Documented support and estimated memory do not establish response speed.

Limits and troubleshooting

  • Publisher model card places any deployed use outside scope. This private fixed-input research prototype must not be marketed as production suitable, safe, fair or calibrated; no automatic or consequential decisions.
  • ViT-B/32 is an explicitly selected representative inside frozen CLIP family. Nine native variants are listed; eight other variants, other backends and broader paired-input workflows remain unqualified.
  • 77 is the native text-encoder token limit per candidate English label including start/end, not pixels, full multimodal context or generated output. Three labels form a text batch3 while one image forms image batch1. Output tokens are not applicable.
  • Native BPE/vocabulary and 224 RGB resize/center crop/normalization are pinned. A whole diagram with embedded dog photographs is not a representative in-domain image dataset. Human inspection and broader fixed-taxonomy testing are still needed.
  • Native image and text features are normalized and compared; learned-scale logits and any taxonomy ranking are relative to labels, not calibrated truth or proof of general image understanding. No exact score/ranking has been measured.
  • The expected native checkpoint digest is publisher-provided and HEAD length captured; no weight body or model execution occurred here. Full fit, speed, latency and memory peak are unknown.
  • Native jit=False CPU loading converts to float32. No autoregressive K/V cache, generation sampler, chat template or reasoning mode applies.
  • Reader-authored HTTPServer is a serial experimental loopback harness with strict fixed JSON, body bound and socket-read timeout. It has no generation deadline, public TLS or production resilience.
  • 32 GiB RAM, 40 GiB disk and four threads are planning allocations. Original dated compute/storage and unknown egress/admin/local power remain separate; no hardware performance is inferred.
  • System/transitive package dependencies resolve at installation; save actual versions and logs. Python syntax and fake-encoder transport tests do not establish actual model/dependency compatibility or quality.
Hash, shape or tokenizer assertion failure
Stop. Restore exact pinned native source/BPE, publisher checkpoint and fixture; do not bypass native 77-token-per-label error or silently truncate.
401 or request rejected
Use the matching private key and exact fixed fixture JSON. Arbitrary prompts, labels, uploads and remote URLs are intentionally not accepted by this experiment.
Unexpected ranking
Inspect the diagram and its embedded photographs, fixed English labels and preprocessing. Record the result without inventing expected scores or treating the highest label as calibrated truth. Any input/taxonomy change needs new experimental validation, not a claim of another completed guide.
Memory or package load failure
Stop and inspect available memory and exact CPU dependencies. Record errors; full fit is unmeasured. Do not claim successful model execution from transport-only tests.

Stop the model

  1. 1. Stop the experiment

    Press Ctrl+C in the server terminal and unset keys in client shells. Confirm loopback port no longer serves.

    Command
    unset CLIP_RESEARCH_KEY

    Expected result: Python research harness stops; loopback port 8996 no longer serves.

Uninstall

  1. 1. Remove dedicated experiment files

    Preserve wanted logs/results first and confirm the dedicated path. Shared system packages may remain.

    Command
    rm -r -- "$HOME/clip-research"

    Expected result: Dedicated checkpoint, fixture, native checkout, environment and key removed.

Sources and verification

Sources checked Oct 16, 2026. Verification source

Compare this configuration
Cloud serverDocumented setupSources checked Oct 16, 2026

Compare fixed CLIP image/text inputs on a private research CPU VM

Reproduce a private, fixed-input ViT-B/32 research check with OpenAI’s native CLIP code, checkpoint, BPE vocabulary and publisher diagram fixture. Compare three fixed English labels through normalized 512-dimensional embeddings and similarity logits. The native text limit is 77 tokens per label, including start/end tokens. This educational loopback prototype is not a production service or calibrated classifier; publisher model card places any deployed use outside scope. Fit and performance are unmeasured.

Hardware
AWS r7i.xlarge, 32 GiB RAM, Ubuntu x86_64
Runtime
Native OpenAI CLIP CPU paired-input private research wrapper OpenAI CLIP d05afc436d78f1c48dc0dbf8e5980a9d471f35f6; torch 2.6.0+cpu; torchvision 0.21.0+cpu; Python 3.12 · CPU
Model format
PyTorch JIT checkpoint · Native CPU float32 eager model loaded with jit=False · No quantization; native eager CPU load converts model to float32
Workload
77 token context · 1 concurrent

Based on source documentation; this setup has not been executed by OpenTools. Memory: unknown. No compatible measurement available.

Read the complete setup guide

Before you start

  • Use Ubuntu 24.04 x86_64 on AWS r7i.xlarge, four vCPUs and 32 GiB RAM, in us-east-1 with a 40 GiB gp3 root disk. Use an existing SSH key, restrict port 22 to your client IP and keep port 8996 closed to the network. Confirm quote, quota and capacity before any billable provisioning.
  • Experimental private research only. The native model card places any deployed use outside scope; this educational loopback wrapper is a reproducible test harness, not production-safe hosting or a calibrated classifier. Do not use scores for automatic or consequential decisions.
  • Use only the exact publisher architecture diagram fixture and fixed English labels a diagram / a dog / a cat. No uploads, arbitrary URLs or user-defined taxonomy are accepted. Confirm the intended use and retain MIT notices.
  • 32 GiB RAM, 40 GiB disk and four threads are planning allocations, not measured fit. The chosen ViT-B/32 is one of nine native released variants; the other eight and broader workflows remain unqualified.

Exact model and requirements

Artifact:
OpenAI / CLIP ViT-B/32 native checkpoint (representative family variant) · checkpoint openai/CLIP ViT-B/32
Publisher revision:
d05afc436d78f1c48dc0dbf8e5980a9d471f35f6
Artifact digest:
sha256:40d365715913c9da98579312b702a82c18be219cc2a73407c4526f58eba950af
Download size:
0.33 GiB
Memory requirement (unknown):
Unknown — No exact full-process peak for native CLIP ViT-B/32 CPU float32, image/text encoders, preprocessing and wrapper.
System RAM / disk:
Unknown / Unknown
Placement:
single device. One CPU host; no tensor/pipeline sharding. Entire model on CPU; no device_map, GPU or disk offload.
KV cache:
Non-autoregressive paired encoders; no chat/generation K/V cache is configured.
Workload:
77 token context; Unknown; Not applicable; concurrency 1; batch 1; cache unknown; repetitions Unknown.
Tokenizer:
Native CLIP SimpleTokenizer and exact bpe_simple_vocab_16e6.txt.gz · d05afc436d78f1c48dc0dbf8e5980a9d471f35f6
Sampling / reasoning:
No text sampling. Three fixed labels: a diagram, a dog, a cat; fixed publisher CLIP.png. Native resize/center crop to 224 RGB and normalization; image batch 1, text batch 3 padded to 77. No silent truncation. No chat, reasoning, instruction template, text generation or tool execution. Embeddings are normalized before cosine similarity; logits use native learned logit_scale. Relative label scores are not calibrated probabilities or universal truth.
Runtime prerequisites:
Ubuntu 24.04 x86_64; See prerequisites above.

Official artifact · License

Native OpenAI CLIP repository MIT license and OpenAI-owned ViT-B/32 card MIT declaration are archived; retain copyright/license notices. Native model card recommends research and identifies any deployed use as out of scope. This fixed-input private educational experiment does not establish deployment suitability, safety, fairness, calibration or legal clearance. Inputs/labels are English; no automatic decisions or consequential classification.

  • 353,976,522 bytes is publisher expected checkpoint content length from HEAD metadata, not a downloaded weight-body measurement or full runtime RAM requirement.
  • 32 GiB RAM, 40 GiB disk and four threads are author planning allocations, not measured minima. Both encoders, preprocessing, buffers, dependencies and OS add memory/storage.

One-time setup and hardware

hardware
Not applicable — AWS hardware acquisition is included in compute rental; no purchased GPU required. Any separate hardware cost is not applicable.
AWS hardware acquisition is included in compute rental; no purchased GPU required. Any separate hardware cost is not applicable. Tax: unknown.
setup
Unknown — Initial provisioning/build time and labor cost are unknown.
Initial provisioning/build time and labor cost are unknown. Tax: unknown.

Recurring costs

compute
$0.26 / hour
AWS public us-east-1 Linux On-Demand rate USD 0.2646 per billed instance-hour, no paid preinstalled software. Eight hours USD 2.1168; 24 hours USD 6.3504 compute. Idle running hours bill. Storage, egress, tax and administration separate; no Spot/reservation/discount assumed. Capacity/quota unverified. Region: us-east-1. SKU: r7i.xlarge Linux On-Demand. Tax: excluded. Price dated Oct 15, 2026. Price source
storage
$0.08 / GB month
US East (N. Virginia) gp3 USD 0.08 per GB-month; AWS defines GB as 1024^3 bytes. Selected 40 GiB root volume is USD 3.20 per full month, prorated by provisioned duration. Baseline 3000 IOPS / 125 MB/s; no extras assumed. Retained snapshots/resources separate; storage persists after instance stop. Tax excluded. Region: us-east-1. SKU: EBS gp3 baseline 3000 IOPS / 125 MB/s. Tax: excluded. Price dated Oct 16, 2026. Price source
egress
Unknown — Data transfer price, allowances and traffic volume are unknown.
Data transfer price, allowances and traffic volume are unknown. Tax: unknown.
administration
Unknown — Maintenance labor rate and hours are unknown.
Maintenance labor rate and hours are unknown. Tax: unknown.

Install the runtime

  1. 1. Create the pinned CPU research environment

    Install hashed official CPU wheels and exact native CLIP source. CLIP dependencies/transitive packages resolve at installation; save pip freeze and stop on pip check errors. This is documented compatibility, not an executed environment.

    Command
    sudo apt-get update
    sudo apt-get install -y python3.12 python3.12-venv git curl ca-certificates openssl
    mkdir -p "$HOME/clip-research/models" "$HOME/clip-research/fixture"
    cd "$HOME/clip-research"
    python3.12 -m venv .venv
    .venv/bin/python -m pip install "https://download.pytorch.org/whl/cpu/torch-2.6.0%2Bcpu-cp312-cp312-linux_x86_64.whl#sha256=59e78aa0c690f70734e42670036d6b541930b8eabbaa18d94e090abf14cc4d91" "https://download-r2.pytorch.org/whl/cpu/torchvision-0.21.0%2Bcpu-cp312-cp312-linux_x86_64.whl#sha256=d6874431e678ba107b60a83f255c33f3755f06bad587b1b919aa514ec325dcd8"
    git clone https://github.com/openai/CLIP.git native-clip
    git -C native-clip checkout --detach d05afc436d78f1c48dc0dbf8e5980a9d471f35f6
    .venv/bin/python -m pip install ./native-clip
    .venv/bin/python -m pip check
    .venv/bin/python -m pip freeze > resolved-environment.txt

    Expected result: Exact checkout and CPU wheel hashes resolve; pip check passes and actual environment is recorded. No GPU driver required.

Download the model

  1. 1. Verify checkpoint, native tokenizer vocabulary and fixed fixture

    Only the reader following this guide downloads the weight body. The publisher URL contains the expected SHA-256 and archived HEAD reports 353,976,522 bytes; this author did not download it. Verify every selected input before load.

    Command
    cd "$HOME/clip-research"
    curl --fail --location --output models/ViT-B-32.pt 'https://openaipublic.azureedge.net/clip/models/40d365715913c9da98579312b702a82c18be219cc2a73407c4526f58eba950af/ViT-B-32.pt'
    curl --fail --location --output fixture/CLIP.png 'https://raw.githubusercontent.com/openai/CLIP/d05afc436d78f1c48dc0dbf8e5980a9d471f35f6/CLIP.png'
    sha256sum --check <<'SHA256'
    40d365715913c9da98579312b702a82c18be219cc2a73407c4526f58eba950af  models/ViT-B-32.pt
    308a3ca4503f1c7a07803916c369d78c4ef501e5ab7fc727da9b5e1d2f9ec85b  fixture/CLIP.png
    924691ac288e54409236115652ad4aa250f48203de50a9e4722a6ecd48d6804a  native-clip/clip/bpe_simple_vocab_16e6.txt.gz
    SHA256

    Expected result: All three expected hashes report OK. Stop on mismatch. Only trusted publisher checkpoint is used; no arbitrary PyTorch file input.

Configure

  1. 1. Create a private research key

    Create a local service key only when absent; preserve existing access and do not print or share it. This is not a provider API key.

    Command
    cd "$HOME/clip-research"
    umask 077
    if [ ! -e .api-key ]; then openssl rand -hex 32 > .api-key; fi
    test -s .api-key || { echo "Restore empty key before continuing"; exit 1; }
    chmod 600 .api-key

    Expected result: Private nonempty .api-key exists; existing key preserved.

  2. 2. Create the fixed-input research harness

    Reader-authored serial HTTPServer binds loopback and accepts only a fixed fixture identifier. It provides no production service guarantees. It loads the exact local image/model and fixed labels; it does not fetch URLs or accept uploads.

    Command
    cd "$HOME/clip-research"
    cat > clip_research.py <<'PYSERVER'
    """OpenTools reader-authored educational demonstrator; not publisher server."""
    import hmac,json,os
    from http.server import BaseHTTPRequestHandler,HTTPServer
    
    def handler_factory(generate,key):
        class Handler(BaseHTTPRequestHandler):
            protocol_version='HTTP/1.0'
            def setup(self):
                super().setup(); self.connection.settimeout(10)
            def log_message(self,*args): pass
            def reply(self,status,data):
                body=json.dumps(data,ensure_ascii=False).encode()
                self.send_response(status); self.send_header('Content-Type','application/json; charset=utf-8')
                self.send_header('Content-Length',str(len(body))); self.end_headers(); self.wfile.write(body)
            def authorized(self):
                value=self.headers.get('Authorization','').encode()
                return hmac.compare_digest(value,('Bearer '+key).encode())
            def do_GET(self):
                if not self.authorized(): return self.reply(401,{'error':'unauthorized'})
                if self.path!='/health': return self.reply(404,{'error':'not_found'})
                self.reply(200,{'status':'ready'})
            def do_POST(self):
                if not self.authorized(): return self.reply(401,{'error':'unauthorized'})
                if self.path!='/v1/clip-research': return self.reply(404,{'error':'not_found'})
                if self.headers.get('Transfer-Encoding') is not None: return self.reply(400,{'error':'transfer_encoding_unsupported'})
                if self.headers.get_content_type()!='application/json': return self.reply(415,{'error':'json_required'})
                lengths=self.headers.get_all('Content-Length',[])
                if len(lengths)!=1 or not lengths[0] or not all('0'<=c<='9' for c in lengths[0]): return self.reply(411,{'error':'content_length_required'})
                if len(lengths[0])>4: return self.reply(413,{'error':'body_limit'})
                n=int(lengths[0])
                if not 1<=n<=1024: return self.reply(413,{'error':'body_limit'})
                try:
                    raw=self.rfile.read(n)
                    if len(raw)!=n: return self.reply(400,{'error':'incomplete_body'})
                    data=json.loads(raw)
                except (ValueError,UnicodeError,TimeoutError): return self.reply(400,{'error':'invalid_json'})
                if type(data)!=dict or data!={'fixture':'publisher-clip-diagram'}:
                    return self.reply(400,{'error':'fixed_fixture_required'})
                try: result=generate()
                except Exception: return self.reply(500,{'error':'generation_failed'})
                self.reply(200,result)
        return Handler
    
    def main():
        import torch,clip
        from PIL import Image
        from clip.simple_tokenizer import SimpleTokenizer
        key=open('.api-key',encoding='ascii').read().strip()
        if len(key)!=64 or any(c not in '0123456789abcdef' for c in key): raise SystemExit('Invalid service key')
        torch.set_num_threads(4)
        model,preprocess=clip.load('models/ViT-B-32.pt',device='cpu',jit=False)
        model.eval()
        labels=['a diagram','a dog','a cat']
        tokenizer=SimpleTokenizer()
        counts=[len(tokenizer.encode(x))+2 for x in labels]
        assert all(2<=n<=77 for n in counts)
        tokens=clip.tokenize(labels,context_length=77,truncate=False)
        assert list(tokens.shape)==[3,77]
        with Image.open('fixture/CLIP.png') as im:
            assert im.size==(2162,762)
            image=preprocess(im.convert('RGB')).unsqueeze(0)
        assert list(image.shape)==[1,3,224,224]
        def generate():
            with torch.inference_mode():
                i=model.encode_image(image).float()
                t=model.encode_text(tokens).float()
                assert list(i.shape)==[1,512] and list(t.shape)==[3,512]
                i=i/i.norm(dim=-1,keepdim=True)
                t=t/t.norm(dim=-1,keepdim=True)
                cosine=i@t.T
                logits=model.logit_scale.exp()*cosine
                assert torch.isfinite(cosine).all() and torch.isfinite(logits).all()
            return {'scope':'private research only; deployed use is outside publisher scope','fixture':'publisher-clip-diagram','labels':labels,'text_tokens_including_bos_eos':counts,'padded_text_shape':[3,77],'image_shape':[1,3,224,224],'image_embedding_shape':[1,512],'text_embedding_shape':[3,512],'cosine':cosine[0].tolist(),'logits':logits[0].tolist(),'highest_label':labels[int(logits[0].argmax())],'calibrated':False}
        HTTPServer(('127.0.0.1',8996),handler_factory(generate,key)).serve_forever()
    if __name__=='__main__': main()
    PYSERVER
    .venv/bin/python -m py_compile clip_research.py

    Expected result: Python syntax check passes without loading the model.

Start the model

  1. 1. Start the private fixed-input experiment

    In a foreground terminal, load native eager CPU float32 with four threads. Startup verifies input shapes and native text length per fixed label. One request at a time; no public listener, batching service or automatic decisions.

    Command
    cd "$HOME/clip-research"
    .venv/bin/python clip_research.py

    Expected result: After source-supported but unexecuted load, authenticated health can report ready. Stop on missing input, token overflow or preprocessing assertion.

Connect to your endpoint

http://127.0.0.1:8996/v1/clip-research

Research VM loopback only. Client may use ssh -N -L 8996:127.0.0.1:8996 USER@VM_IP with existing SSH access; keep EC2 8996 closed. The shown checks run on the server.

Access: loopback. Private Bearer key required for health and research request. Exact JSON body fixture=publisher-clip-diagram only. No image uploads, arbitrary URLs, prompts or new labels. This is a reader-authored experimental harness, not publisher deployment guidance.

Verify the setup

  1. 1. Inspect paired-input research output

    Run from a second terminal on the server. Confirm exact fixed labels, token counts <=77 including start/end, padded text shape 3x77, image 1x3x224x224, embedding shapes 1x512 and 3x512, and three finite cosine/logit values. The source fixture is an architecture diagram containing dog photographs; inspect this taxonomy limitation yourself. Ranking must be internally consistent with reported logits, but no exact ranking or number is promised. A shape/finite smoke check is not in-domain quality, calibration, bias or deployment validation.

    Command
    cd "$HOME/clip-research"
    CLIP_RESEARCH_KEY="$(cat .api-key)"
    curl --fail http://127.0.0.1:8996/health -H "Authorization: Bearer $CLIP_RESEARCH_KEY"
    curl --fail http://127.0.0.1:8996/v1/clip-research -H "Authorization: Bearer $CLIP_RESEARCH_KEY" -H 'Content-Type: application/json' -d '{"fixture":"publisher-clip-diagram"}'
    curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8996/health
    unset CLIP_RESEARCH_KEY

    Expected result: Authorized health ready; research JSON contains shapes, per-label counts, finite cosine/logits and highest_label derived from those logits, calibrated=false. Missing key returns 401. No actual model result is claimed.

Performance evidence

No compatible measurement available. Documented support and estimated memory do not establish response speed.

Limits and troubleshooting

  • Publisher model card places any deployed use outside scope. This private fixed-input research prototype must not be marketed as production suitable, safe, fair or calibrated; no automatic or consequential decisions.
  • ViT-B/32 is an explicitly selected representative inside frozen CLIP family. Nine native variants are listed; eight other variants, other backends and broader paired-input workflows remain unqualified.
  • 77 is the native text-encoder token limit per candidate English label including start/end, not pixels, full multimodal context or generated output. Three labels form a text batch3 while one image forms image batch1. Output tokens are not applicable.
  • Native BPE/vocabulary and 224 RGB resize/center crop/normalization are pinned. A whole diagram with embedded dog photographs is not a representative in-domain image dataset. Human inspection and broader fixed-taxonomy testing are still needed.
  • Native image and text features are normalized and compared; learned-scale logits and any taxonomy ranking are relative to labels, not calibrated truth or proof of general image understanding. No exact score/ranking has been measured.
  • The expected native checkpoint digest is publisher-provided and HEAD length captured; no weight body or model execution occurred here. Full fit, speed, latency and memory peak are unknown.
  • Native jit=False CPU loading converts to float32. No autoregressive K/V cache, generation sampler, chat template or reasoning mode applies.
  • Reader-authored HTTPServer is a serial experimental loopback harness with strict fixed JSON, body bound and socket-read timeout. It has no generation deadline, public TLS or production resilience.
  • 32 GiB RAM, 40 GiB disk and four threads are planning allocations. Original dated compute/storage and unknown egress/admin/local power remain separate; no hardware performance is inferred.
  • System/transitive package dependencies resolve at installation; save actual versions and logs. Python syntax and fake-encoder transport tests do not establish actual model/dependency compatibility or quality.
Hash, shape or tokenizer assertion failure
Stop. Restore exact pinned native source/BPE, publisher checkpoint and fixture; do not bypass native 77-token-per-label error or silently truncate.
401 or request rejected
Use the matching private key and exact fixed fixture JSON. Arbitrary prompts, labels, uploads and remote URLs are intentionally not accepted by this experiment.
Unexpected ranking
Inspect the diagram and its embedded photographs, fixed English labels and preprocessing. Record the result without inventing expected scores or treating the highest label as calibrated truth. Any input/taxonomy change needs new experimental validation, not a claim of another completed guide.
Memory or package load failure
Stop and inspect available memory and exact CPU dependencies. Record errors; full fit is unmeasured. Do not claim successful model execution from transport-only tests.

Stop the model

  1. 1. Stop the experiment

    Press Ctrl+C in the server terminal and unset keys in client shells. Close SSH tunnel; stopping Python does not stop VM billing.

    Command
    unset CLIP_RESEARCH_KEY

    Expected result: Python research harness stops; loopback port 8996 no longer serves.

Uninstall

  1. 1. Remove dedicated experiment files

    Preserve wanted logs/results first and confirm the dedicated path. Shared system packages may remain.

    Command
    rm -r -- "$HOME/clip-research"

    Expected result: Dedicated checkpoint, fixture, native checkout, environment and key removed.

Shut down cloud resources

  1. 1. End cloud billing resources

    In EC2 us-east-1, stop for later reuse or terminate this exact VM. Review Delete on termination for its root volume. Delete unwanted detached EBS volumes, snapshots and reserved/Elastic/public IP resources. Stopped VM storage and retained resources may still bill. Check Bills/Cost Explorer later for final usage.

    Expected result: Exact instance is stopped/terminated as intended; no unwanted attached/retained billed resources remain. Instance compute stops only after its lifecycle transition, not when the Python service stops.

Sources and verification

Sources checked Oct 16, 2026. Verification source

Compare this configuration
Local hardwareDocumented setupSources checked Oct 17, 2026

Compare native CLIP 336px image/text similarities on a research CPU desktop

Use the publisher-native ViT-L/14@336px checkpoint with both image and text encoders. Compare two original reader-generated RGB shape images against two fixed English descriptions using 768-dimensional normalized embeddings and relative similarities. This higher-resolution family variant has a 24 × 24 patch grid plus one class position; text remains limited to 77 tokens per label. The publisher places any deployed use outside scope, including private deployment; this educational protocol reproducer does not establish intended-use clearance, in-domain quality, calibration or production suitability. Fit and speed are unmeasured.

Hardware
Intel Core i5-12400 desktop, 4 inference threads, 32 GiB RAM
Runtime
Native CLIP ViT-L/14 at 336px paired-input CPU research OpenAI CLIP d05afc4; Torch 2.6.0 CPU; torchvision 0.21.0 CPU; Python 3.12 · CPU
Model format
PyTorch JIT checkpoint · Native eager CPU FP32, jit=False; both complete encoders retained · Unquantized publisher JIT checkpoint; native eager CPU load uses FP32
Workload
77 token context · 1 concurrent

Based on source documentation; this setup has not been executed by OpenTools. Memory: unknown. No compatible measurement available.

Read the complete setup guide

Before you start

  • Use an owned Intel Core i5-12400 desktop with Ubuntu 24.04 x86_64, 32 GiB installed RAM and 40 GiB free disk. Allocate four inference threads and build natively on the same host.
  • Review the native MIT terms and publisher research-use model card. Any deployed use, commercial or not, is outside the publisher scope; private/cloud location is not an exemption. This educational fixed-input reproducer is not approved for deployment, automatic or consequential decisions. Even non-deployed fixed-taxonomy use needs thorough in-domain testing beyond this smoke check.
  • Use only the two original RGB fixtures generated from the supplied drawing code and the two exact English labels. No user uploads, remote media, paths, new labels or arbitrary model choices are accepted. No person images or third-party media rights are involved.
  • ViT-L/14@336px is an explicitly selected native variant inside the frozen generic CLIP family, not a canonical rename or byte-equivalent B32/HF checkpoint. Its full vision/text encoders, 336px preprocessing and 768-dimensional projections are retained. Other released variants and broader workflows remain open.

Exact model and requirements

Artifact:
OpenAI / Native CLIP ViT-L/14@336px; explicit higher-resolution family variant · checkpoint openai/CLIP ViT-L/14@336px
Publisher revision:
d05afc436d78f1c48dc0dbf8e5980a9d471f35f6
Artifact digest:
sha256:3035c92b350959924f9f00213499208652fc7ea050643e8b385c2dac08641f02
Download size:
Unknown
Memory requirement (unknown):
Unknown — Full native CPU model, preprocessing, text/image attention, buffers and process peak have not been measured.
System RAM / disk:
Unknown / Unknown
Placement:
single device. One CPU host; no tensor/pipeline sharding. Entire model on CPU; no device_map, GPU or disk offload.
KV cache:
CLIP paired encoders do not generate autoregressively or retain a chat K/V cache.
Workload:
77 token context; Unknown; Not applicable; concurrency 1; batch 1; cache cold; repetitions Unknown.
Tokenizer:
Native CLIP SimpleTokenizer, pinned packaged BPE; 77 positions per label including BOS/EOS · d05afc436d78f1c48dc0dbf8e5980a9d471f35f6
Sampling / reasoning:
No generation sampler or chat template. Fixed English labels: a red rectangle on a white background; a blue circle on a white background. Two original 336 × 336 RGB images are generated locally by the reader. Native bicubic Resize, CenterCrop, RGB conversion, ToTensor and exact CLIP normalization. Images encoded serially with batch 1; two labels form text batch 2 padded to 77, truncate=False. The native image transformer has 336/14 = 24 patches per side, 576 patch positions plus one learned class position = 577. This visual sequence is distinct from the per-label 77 text context and from the 768-dimensional projected embeddings. Both encoders are complete; no text generation, decoded output, reasoning or tool execution applies. HF publisher config is corroborating architecture metadata only; native loader shape checks bind the reader-selected native checkpoint, with no native/HF byte-equivalence claim.
Runtime prerequisites:
Ubuntu 24.04 x86_64; See prerequisites above.

Official artifact · License

Actual native OpenAI CLIP repository MIT license is archived; retain notices. The same repository lists this exact publisher checkpoint in its native model map and describes its April 2022 release. No separate HF checkpoint grant or byte equality is inferred. Publisher model card places any deployed use, commercial or not, outside scope and requires thorough in-domain fixed-taxonomy testing even for constrained non-deployed image search. Private/cloud use is not an exemption. This documented educational reproducer supplies no deployment suitability, bias/safety assessment, calibrated accuracy or legal clearance; no surveillance, face recognition, consequential or automatic decisions.

  • Architecture accounting gives 427,944,193 scalar parameters and 1,711,776,772 bytes if all are FP32; this source-derived parameter-storage estimate is not observed checkpoint bytes, total resident RAM, peak or fit. Native reader architecture checks must pass.
  • 32 GiB RAM / 40 GiB disk / four threads are reused planning allocations, not measured minima. Native JIT and eager state may coexist during loading; tokenizer, two image tensors, dependency environment, buffers and OS add unknown overhead.
  • The native serialized checkpoint size is unknown; no HEAD or body was requested. Separate HF serialization metadata is not substituted for this native artifact.

One-time setup and hardware

hardware
Unknown — Existing desktop purchase price and incremental hardware cost depend on the reader; unknown.
Existing desktop purchase price and incremental hardware cost depend on the reader; unknown. Tax: unknown.
setup
Unknown — Initial provisioning/build time and labor cost are unknown.
Initial provisioning/build time and labor cost are unknown. Tax: unknown.

Recurring costs

electricity
Unknown — Actual wall power, electricity rate and powered hours are unknown; no TDP-to-wall-power conversion.
Actual wall power, electricity rate and powered hours are unknown; no TDP-to-wall-power conversion. Tax: unknown.
storage
Unknown — Incremental cost of local disk capacity is unknown. The 40 GiB free-disk walkthrough allocation is an author choice, not a measured requirement.
Incremental cost of local disk capacity is unknown. The 40 GiB free-disk walkthrough allocation is an author choice, not a measured requirement. Tax: unknown.
egress
Unknown — Data transfer price, allowances and traffic volume are unknown.
Data transfer price, allowances and traffic volume are unknown. Tax: unknown.
administration
Unknown — Maintenance labor rate and hours are unknown.
Maintenance labor rate and hours are unknown. Tax: unknown.

Install the runtime

  1. 1. Create the pinned CPU research environment

    Install hashed official CPU wheels and exact native CLIP source. CLIP dependencies/transitive packages resolve at installation; save pip freeze and stop on pip check errors. This is documented compatibility, not an executed environment. The source package uses the same accepted CPU stack as the B32 guide; changing native architecture is verified by explicit reader loading/shape guards, not inferred execution.

    Command
    set -e
    sudo apt-get update
    sudo apt-get install -y python3.12 python3.12-venv git curl ca-certificates openssl
    mkdir -p "$HOME/clip336-research/models" "$HOME/clip336-research/fixture"
    cd "$HOME/clip336-research"
    python3.12 -m venv .venv
    .venv/bin/python -m pip install "https://download.pytorch.org/whl/cpu/torch-2.6.0%2Bcpu-cp312-cp312-linux_x86_64.whl#sha256=59e78aa0c690f70734e42670036d6b541930b8eabbaa18d94e090abf14cc4d91" "https://download-r2.pytorch.org/whl/cpu/torchvision-0.21.0%2Bcpu-cp312-cp312-linux_x86_64.whl#sha256=d6874431e678ba107b60a83f255c33f3755f06bad587b1b919aa514ec325dcd8"
    git clone https://github.com/openai/CLIP.git native-clip
    git -C native-clip checkout --detach d05afc436d78f1c48dc0dbf8e5980a9d471f35f6
    .venv/bin/python -m pip install ./native-clip
    .venv/bin/python -m pip check
    .venv/bin/python -m pip freeze > resolved-environment.txt

    Expected result: Exact checkout and CPU wheel hashes resolve; pip check passes and actual environment is recorded. No GPU driver required.

Download the model

  1. 1. Verify the exact native 336px checkpoint and packaged vocabulary

    Only the reader performs this download. The expected digest is literally the parent path of the pinned native OpenAI URL. Exact native file size remains unknown here; no weight body, HEAD or range was requested. Verify complete bytes before native import/load; do not use a similarly named HF or 224px artifact.

    Command
    set -e
    cd "$HOME/clip336-research"
    curl --fail --location --output models/ViT-L-14-336px.pt 'https://openaipublic.azureedge.net/clip/models/3035c92b350959924f9f00213499208652fc7ea050643e8b385c2dac08641f02/ViT-L-14-336px.pt'
    sha256sum --check <<'SHA256'
    3035c92b350959924f9f00213499208652fc7ea050643e8b385c2dac08641f02  models/ViT-L-14-336px.pt
    924691ac288e54409236115652ad4aa250f48203de50a9e4722a6ecd48d6804a  native-clip/clip/bpe_simple_vocab_16e6.txt.gz
    SHA256

    Expected result: Both complete hash checks report OK; stop on mismatch. The reader-generated fixtures are created later, with no remote media download or invented publisher fixture digest.

Configure

  1. 1. Create a private research key

    Create a local service key only when absent; preserve existing access and do not print or share it. This is not a provider API key.

    Command
    set -e
    cd "$HOME/clip336-research"
    umask 077
    if [ ! -e .api-key ]; then openssl rand -hex 32 > .api-key; fi
    test -s .api-key || { echo "Restore empty key before continuing"; exit 1; }
    chmod 600 .api-key

    Expected result: Private nonempty .api-key exists; existing key preserved.

  2. 2. Create the native paired-encoder adapter

    Reader-authored code verifies the trusted native checkpoint digest before native imports, loads the exact local file with native jit=False CPU handling and checks full architecture/dtype/finite parameters. It creates two original RGB geometry fixtures and validates native preprocessing/text lengths. This is not publisher server code.

    Command
    set -e
    cd "$HOME/clip336-research"
    cat > clip_research.py <<'PYCORE'
    """Reader-authored CLIP native336 fixed paired-image/text research; not publisher server."""
    import hashlib,hmac,json,math,pathlib
    from http.server import BaseHTTPRequestHandler,HTTPServer
    ROOT=pathlib.Path(__file__).resolve().parent
    PORT=8998
    MODEL_SHA='3035c92b350959924f9f00213499208652fc7ea050643e8b385c2dac08641f02'
    LABELS=['a red rectangle on a white background','a blue circle on a white background']
    
    def validate_result(result):
        if type(result)is not dict or set(result)!={'cosine','logits','token_counts'}:raise ValueError('result_schema')
        counts=result['token_counts']
        if type(counts)is not list or len(counts)!=2 or any(type(x)is not int or not 2<=x<=77 for x in counts):raise ValueError('token_counts')
        for name in ['cosine','logits']:
            matrix=result[name]
            if type(matrix)is not list or len(matrix)!=2:raise ValueError('matrix_shape')
            for row in matrix:
                if type(row)is not list or len(row)!=2 or any(type(x)not in(int,float)or not math.isfinite(x)for x in row):raise ValueError('nonfinite_or_shape')
                if name=='cosine'and any(not -1.00001<=x<=1.00001 for x in row):raise ValueError('cosine_range')
        return {'fixture':'author-shapes-v1','variant':'ViT-L/14@336px','labels':LABELS,'fixture_names':['red-rectangle','blue-circle'],'text_tokens_including_bos_eos':counts,'padded_text_shape':[2,77],'image_shape_per_call':[1,3,336,336],'image_embedding_shape_per_call':[1,768],'text_embedding_shape':[2,768],'vision_positions_per_image':577,'cosine':result['cosine'],'logits':result['logits'],'highest_labels':[LABELS[max(range(2),key=lambda i:row[i])]for row in result['logits']],'calibrated':False,'generated_text_tokens':None}
    
    def make_encoder():
        artifact=ROOT/'models/ViT-L-14-336px.pt'
        h=hashlib.sha256()
        with artifact.open('rb')as f:
            for block in iter(lambda:f.read(1048576),b''):h.update(block)
        if h.hexdigest()!=MODEL_SHA:raise RuntimeError('checkpoint_hash')
        # Native imports are only in the reader-run path, after trusted artifact verification.
        import torch,clip
        from PIL import Image,ImageDraw
        from clip.simple_tokenizer import SimpleTokenizer
        torch.set_num_threads(4)
        model,preprocess=clip.load(str(artifact),device='cpu',jit=False)
        model=model.float().eval()
        if model.visual.input_resolution!=336 or tuple(model.visual.conv1.kernel_size)!=(14,14):raise RuntimeError('variant_dimensions')
        if list(model.visual.positional_embedding.shape)!=[577,1024]or len(model.visual.transformer.resblocks)!=24:raise RuntimeError('vision_architecture')
        if model.context_length!=77 or list(model.text_projection.shape)!=[768,768]:raise RuntimeError('text_architecture')
        if any(p.device.type!='cpu'or p.is_floating_point()and p.dtype!=torch.float32 for p in model.parameters()):raise RuntimeError('cpu_fp32')
        if any(not torch.isfinite(p).all()for p in model.parameters()):raise RuntimeError('nonfinite_weights')
        tokenizer=SimpleTokenizer();counts=[len(tokenizer.encode(x))+2 for x in LABELS]
        tokens=clip.tokenize(LABELS,context_length=77,truncate=False)
        if list(tokens.shape)!=[2,77]or any(not 2<=n<=77 for n in counts):raise RuntimeError('text_budget')
        folder=ROOT/'fixture';folder.mkdir(exist_ok=True);images=[]
        # Original RGB images made by the reader; no downloaded media or external rights.
        for name in ['red-rectangle','blue-circle']:
            im=Image.new('RGB',(336,336),(255,255,255));draw=ImageDraw.Draw(im)
            if name=='red-rectangle':draw.rectangle((56,104,280,232),fill=(220,30,30))
            else:draw.ellipse((72,72,264,264),fill=(30,70,220))
            im.save(folder/(name+'.png'))
            image=preprocess(im).unsqueeze(0)
            if list(image.shape)!=[1,3,336,336]or not torch.isfinite(image).all():raise RuntimeError('preprocess')
            images.append(image)
        def encode():
            with torch.inference_mode():
                t=model.encode_text(tokens).float()
                if list(t.shape)!=[2,768]or not torch.isfinite(t).all()or (t.norm(dim=-1)<=0).any():raise RuntimeError('text_features')
                t=t/t.norm(dim=-1,keepdim=True);cosine=[];logits=[]
                for image in images:
                    i=model.encode_image(image).float()
                    if list(i.shape)!=[1,768]or not torch.isfinite(i).all()or (i.norm(dim=-1)<=0).any():raise RuntimeError('image_features')
                    i=i/i.norm(dim=-1,keepdim=True);c=i@t.T;l=model.logit_scale.exp()*c
                    if not torch.isfinite(c).all()or not torch.isfinite(l).all():raise RuntimeError('similarity')
                    cosine.append(c[0].tolist());logits.append(l[0].tolist())
            return {'cosine':cosine,'logits':logits,'token_counts':counts}
        return encode
    
    PYCORE

    Expected result: Core adapter source written. No model load, tokenizer execution or fixture generation occurs until the reader starts it.

  3. 3. Complete and verify the private transport

    Append the strict serial loopback transport, then verify the exact complete wrapper. Only the fixed fixture identifier is accepted; inputs cannot request files, URLs, labels or model selections.

    Command
    set -e
    cd "$HOME/clip336-research"
    cat >> clip_research.py <<'PYHTTP'
    def create_server(encoder, key, port=PORT):
        if not isinstance(key, str) or len(key) != 64 or any(c not in '0123456789abcdef' for c in key):
            raise ValueError('key_format')
    
        class Handler(BaseHTTPRequestHandler):
            def setup(self):
                super().setup()
                self.connection.settimeout(5)
    
            def log_message(self, *_):
                pass  # Do not log Bearer keys or request bodies.
    
            def reply(self, status, obj):
                data = json.dumps(obj, allow_nan=False, separators=(',', ':')).encode()
                self.send_response(status)
                self.send_header('Content-Type', 'application/json')
                self.send_header('Content-Length', str(len(data)))
                self.send_header('Connection', 'close')
                self.end_headers()
                self.wfile.write(data)
                self.close_connection = True
    
            def authorized(self):
                values = self.headers.get_all('Authorization', [])
                return len(values) == 1 and hmac.compare_digest(values[0].encode(), ('Bearer ' + key).encode())
    
            def do_GET(self):
                if not self.authorized():
                    return self.reply(401, {'error': 'unauthorized'})
                if self.path != '/health':
                    return self.reply(404, {'error': 'not_found'})
                return self.reply(200, {'ready': True, 'text_context_per_label': 77,
                                        'generated_text_tokens': None})
    
            def do_POST(self):
                if not self.authorized():
                    return self.reply(401, {'error': 'unauthorized'})
                if self.path != '/v1/clip-research':
                    return self.reply(404, {'error': 'not_found'})
                if self.headers.get('Transfer-Encoding') is not None:
                    return self.reply(400, {'error': 'transfer_encoding_unsupported'})
                lengths = self.headers.get_all('Content-Length', [])
                if len(lengths) != 1:
                    return self.reply(411, {'error': 'content_length_required'})
                raw = lengths[0]
                if not raw or len(raw) > 4 or any(c not in '0123456789' for c in raw):
                    return self.reply(413, {'error': 'invalid_or_excessive_length'})
                n = int(raw)
                if n < 1 or n > 256:
                    return self.reply(413, {'error': 'body_limit'})
                if self.headers.get_content_type() != 'application/json':
                    return self.reply(415, {'error': 'json_required'})
                try:
                    body = self.rfile.read(n)
                except (TimeoutError, OSError):
                    return self.reply(408, {'error': 'body_timeout'})
                if len(body) != n:
                    return self.reply(400, {'error': 'incomplete_body'})
                try:
                    def unique(pairs):
                        obj = {}
                        for k, v in pairs:
                            if k in obj:
                                raise ValueError('duplicate_key')
                            obj[k] = v
                        return obj
                    request = json.loads(body.decode('utf-8'), object_pairs_hook=unique,
                                         parse_constant=lambda _: (_ for _ in ()).throw(ValueError('constant')))
                except (ValueError, UnicodeError, RecursionError):
                    return self.reply(400, {'error': 'invalid_json'})
                if type(request) is not dict or request != {'fixture': 'author-shapes-v1'}:
                    return self.reply(400, {'error': 'fixed_fixture_required'})
                try:
                    result = validate_result(encoder())
                except Exception:
                    return self.reply(500, {'error': 'predictor_or_mask_failure'})
                return self.reply(200, result)
    
        return HTTPServer(('127.0.0.1', port), Handler)
    
    
    if __name__ == '__main__':
        secret = (ROOT / '.api-key').read_text().strip()
        encoder = make_encoder()
        with create_server(encoder, secret) as server:
            server.serve_forever()
    PYHTTP
    .venv/bin/python -m py_compile clip_research.py
    sha256sum --check <<'SHA256'
    806f8f79957e3fed222aa271651c12a473be3b3e92aa70daaa573c399c8fc3bd  clip_research.py
    SHA256

    Expected result: Python syntax and exact whole-wrapper hash verify without native execution.

Start the model

  1. 1. Start the bounded research reproducer

    Run from the dedicated workspace. The native loader rebuilds the complete checkpoint and loads state_dict with strict default checking, then converts to CPU float32/eval. Startup requires vision resolution 336, patch 14, 577 visual positions, 24 vision blocks and 768 projections; unexpected variants stop. Two images are encoded serially, one request at a time.

    Command
    set -e
    cd "$HOME/clip336-research"
    .venv/bin/python clip_research.py

    Expected result: Only after the reader completes the unexecuted startup checks does loopback 127.0.0.1:8998 serve health. Actual fit, loading success and native results are not claimed.

Connect to your endpoint

http://127.0.0.1:8998/v1/clip-research

Same trusted research desktop loopback only.

Access: loopback. Use the private Bearer key for health and the fixed research request. Send a JSON object with fixture set to author-shapes-v1. The response has two original image names, two fixed English labels, per-label token counts, shape metadata and two-by-two relative similarity matrices. No arbitrary files, URLs, uploads or new labels.

Verify the setup

  1. 1. Inspect finite paired similarities against the actual original images

    Request the fixed experiment from a second server terminal. Check exact labels/fixtures, 77-position padded text, per-label counts including BOS/EOS, serial image shape 1 × 3 × 336 × 336, 768-dimensional projections and two-by-two finite matrices. Open both generated images and inspect whether matched descriptions rank above mismatched descriptions. Record failures and matrix values without requiring a promised ordering or inventing an accuracy result. Geometry is a deliberately simple controlled RGB input, not a natural-image dataset or sufficient in-domain/bias validation.

    Command
    set -e
    cd "$HOME/clip336-research"
    CLIP_RESEARCH_KEY="$(cat .api-key)"
    curl --fail http://127.0.0.1:8998/health -H "Authorization: Bearer $CLIP_RESEARCH_KEY"
    curl --fail http://127.0.0.1:8998/v1/clip-research -H "Authorization: Bearer $CLIP_RESEARCH_KEY" -H 'Content-Type: application/json' -d '{"fixture":"author-shapes-v1"}' -o result.json
    curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8998/health
    unset CLIP_RESEARCH_KEY
    .venv/bin/python - <<'PYVERIFY'
    import json,math
    d=json.load(open('result.json'));labels=['a red rectangle on a white background','a blue circle on a white background']
    assert d['labels']==labels and d['fixture_names']==['red-rectangle','blue-circle']
    assert d['padded_text_shape']==[2,77] and d['image_shape_per_call']==[1,3,336,336]
    assert d['text_embedding_shape']==[2,768] and d['image_embedding_shape_per_call']==[1,768]
    assert d['vision_positions_per_image']==577 and d['generated_text_tokens']is None and d['calibrated']is False
    assert len(d['text_tokens_including_bos_eos'])==2 and all(type(x)is int and 2<=x<=77 for x in d['text_tokens_including_bos_eos'])
    for name in ['cosine','logits']:
     assert len(d[name])==2 and all(len(r)==2 and all(type(x)in(int,float)and math.isfinite(x)for x in r)for r in d[name])
    assert d['highest_labels']==[labels[max(range(2),key=lambda i:r[i])]for r in d['logits']]
    print('Open fixture/red-rectangle.png and fixture/blue-circle.png. Record matched versus mismatched similarities; no ordering or quality guarantee.')
    PYVERIFY

    Expected result: Authorized health and research JSON follow the exact schema; missing authorization returns 401. Structural checks pass only after actual reader execution. Human inspection records rankings and mistakes, without calibration, general accuracy or deployment approval.

Performance evidence

No compatible measurement available. Documented support and estimated memory do not establish response speed.

Limits and troubleshooting

  • Native CLIP model card places any deployed use, commercial or not, outside scope; private/cloud location is not an exemption. The educational fixed-input protocol reproducer does not grant deployment suitability. Non-deployed use still needs thorough fixed-taxonomy in-domain testing; no automatic, consequential, surveillance or face-recognition use.
  • ViT-L/14@336px is a distinct higher-resolution native variant in frozen generic CLIP family. Native expected hash comes from the exact pinned runtime URL; no B32, 224px or HF byte equivalence is claimed. Exact native serialized size is unknown without prohibited body/HEAD/range retrieval.
  • The full model includes a 24-block width-1024 visual encoder and 12-block width-768 text encoder, projected to 768 dimensions. The 336px/14px patch grid gives 576 patches plus one class position. This differs from the B32 guide; no sibling fit, speed or quality transfer.
  • 77 is the native per-label text length including BOS/EOS. It is separate from the 577 visual sequence and 768 embedding dimension; no text generation, chat template, autoregressive K/V cache or decoded output applies.
  • Both original RGB geometry images are generated by the reader; no media was downloaded/generated by this author. Their descriptive labels provide a controlled matched/mismatched comparison, not a representative natural-image dataset. No ranking or score is promised.
  • Embeddings are checked finite/nonzero before normalization; cosine/logits must be finite and correctly shaped. Learned-scale logits and highest-label ranking are relative to two labels, not calibrated probabilities, semantic truth or general recognition accuracy.
  • 32 GiB RAM, 40 GiB disk and four threads are chosen allocations, not minimum requirements or proven fit. Architecture-derived FP32 parameter storage is about 1.71 GB; load-time JIT/eager copies, attention, buffers, environment and OS add unmeasured overhead.
  • The native trusted checkpoint loader first tries torch.jit.load and has a state-dict fallback. Never load arbitrary PyTorch files or relax state-key checking; complete publisher hash verification is mandatory before native import/load.
  • Strict private serial HTTPServer bounds fixed request body, socket read, labels, image count and output matrices. It has no native inference deadline, public TLS or multiuser resilience. A private VM endpoint remains subject to the publisher research-use qualification.
  • Exact direct CPU wheels/native source are pinned as in the accepted stack; transitive/system dependencies resolve at reader install and must be saved with pip freeze. No model import, native tokenizer, preprocessing, load or inference was executed; fake tests only validate transport/output boundaries.
  • Other native variants, arbitrary image search, larger taxonomies, alternative backends/OS and full family scope remain unqualified. This pair is not a final guide denominator.
Hash, architecture, dtype or state-key failure
Stop. Restore the exact native 336px checkpoint/source/BPE and CPU environment. Do not substitute the 224px variant, HF weights or smaller encoders, relax strict state checks or silently truncate text.
Wrong or tied relative rankings
Open both original fixture images and inspect the two fixed descriptions. Record cosine/logit matrices and matched versus mismatched outcomes honestly. No exact order, accuracy, calibration or natural-image generalization is promised.
401 or rejected request
Use the stable private key and exact author-shapes-v1 fixture JSON. Arbitrary file/URL inputs, uploads, custom labels and model changes are rejected.
Native CPU load or memory failure
Stop and record exact dependency versions, available memory and errors. Allocation is unmeasured; do not infer CPU fit from source-only fake tests or delete model components to force a smaller workflow.

Stop the model

  1. 1. Stop the experiment

    Press Ctrl+C in the server terminal and unset keys in client shells. Confirm loopback port no longer serves.

    Command
    set -e
    unset CLIP_RESEARCH_KEY

    Expected result: Python research harness stops; loopback port 8998 no longer serves.

Uninstall

  1. 1. Remove dedicated experiment files

    Preserve wanted logs/results first and confirm the dedicated path. Shared system packages may remain.

    Command
    set -e
    rm -r -- "$HOME/clip336-research"

    Expected result: Dedicated checkpoint, native source, virtualenv, two original fixtures, result JSON, wrapper and private key removed; shared system packages remain.

Sources and verification

Sources checked Oct 17, 2026. Verification source

Compare this configuration
Cloud serverDocumented setupSources checked Oct 17, 2026

Compare native CLIP 336px image/text similarities on a private research CPU VM

Use the publisher-native ViT-L/14@336px checkpoint with both image and text encoders. Compare two original reader-generated RGB shape images against two fixed English descriptions using 768-dimensional normalized embeddings and relative similarities. This higher-resolution family variant has a 24 × 24 patch grid plus one class position; text remains limited to 77 tokens per label. The publisher places any deployed use outside scope, including private deployment; this educational protocol reproducer does not establish intended-use clearance, in-domain quality, calibration or production suitability. Fit and speed are unmeasured.

Hardware
AWS r7i.xlarge, 32 GiB RAM, Ubuntu x86_64
Runtime
Native CLIP ViT-L/14 at 336px paired-input CPU research OpenAI CLIP d05afc4; Torch 2.6.0 CPU; torchvision 0.21.0 CPU; Python 3.12 · CPU
Model format
PyTorch JIT checkpoint · Native eager CPU FP32, jit=False; both complete encoders retained · Unquantized publisher JIT checkpoint; native eager CPU load uses FP32
Workload
77 token context · 1 concurrent

Based on source documentation; this setup has not been executed by OpenTools. Memory: unknown. No compatible measurement available.

Read the complete setup guide

Before you start

  • Use Ubuntu 24.04 x86_64 on AWS r7i.xlarge, four vCPUs and 32 GiB RAM, in us-east-1 with a 40 GiB gp3 root disk. Use an existing SSH key, restrict port 22 to your client IP and keep port 8998 closed to the network. Confirm quote, quota and capacity before any billable provisioning.
  • Review the native MIT terms and publisher research-use model card. Any deployed use, commercial or not, is outside the publisher scope; private/cloud location is not an exemption. This educational fixed-input reproducer is not approved for deployment, automatic or consequential decisions. Even non-deployed fixed-taxonomy use needs thorough in-domain testing beyond this smoke check.
  • Use only the two original RGB fixtures generated from the supplied drawing code and the two exact English labels. No user uploads, remote media, paths, new labels or arbitrary model choices are accepted. No person images or third-party media rights are involved.
  • ViT-L/14@336px is an explicitly selected native variant inside the frozen generic CLIP family, not a canonical rename or byte-equivalent B32/HF checkpoint. Its full vision/text encoders, 336px preprocessing and 768-dimensional projections are retained. Other released variants and broader workflows remain open.

Exact model and requirements

Artifact:
OpenAI / Native CLIP ViT-L/14@336px; explicit higher-resolution family variant · checkpoint openai/CLIP ViT-L/14@336px
Publisher revision:
d05afc436d78f1c48dc0dbf8e5980a9d471f35f6
Artifact digest:
sha256:3035c92b350959924f9f00213499208652fc7ea050643e8b385c2dac08641f02
Download size:
Unknown
Memory requirement (unknown):
Unknown — Full native CPU model, preprocessing, text/image attention, buffers and process peak have not been measured.
System RAM / disk:
Unknown / Unknown
Placement:
single device. One CPU host; no tensor/pipeline sharding. Entire model on CPU; no device_map, GPU or disk offload.
KV cache:
CLIP paired encoders do not generate autoregressively or retain a chat K/V cache.
Workload:
77 token context; Unknown; Not applicable; concurrency 1; batch 1; cache cold; repetitions Unknown.
Tokenizer:
Native CLIP SimpleTokenizer, pinned packaged BPE; 77 positions per label including BOS/EOS · d05afc436d78f1c48dc0dbf8e5980a9d471f35f6
Sampling / reasoning:
No generation sampler or chat template. Fixed English labels: a red rectangle on a white background; a blue circle on a white background. Two original 336 × 336 RGB images are generated locally by the reader. Native bicubic Resize, CenterCrop, RGB conversion, ToTensor and exact CLIP normalization. Images encoded serially with batch 1; two labels form text batch 2 padded to 77, truncate=False. The native image transformer has 336/14 = 24 patches per side, 576 patch positions plus one learned class position = 577. This visual sequence is distinct from the per-label 77 text context and from the 768-dimensional projected embeddings. Both encoders are complete; no text generation, decoded output, reasoning or tool execution applies. HF publisher config is corroborating architecture metadata only; native loader shape checks bind the reader-selected native checkpoint, with no native/HF byte-equivalence claim.
Runtime prerequisites:
Ubuntu 24.04 x86_64; See prerequisites above.

Official artifact · License

Actual native OpenAI CLIP repository MIT license is archived; retain notices. The same repository lists this exact publisher checkpoint in its native model map and describes its April 2022 release. No separate HF checkpoint grant or byte equality is inferred. Publisher model card places any deployed use, commercial or not, outside scope and requires thorough in-domain fixed-taxonomy testing even for constrained non-deployed image search. Private/cloud use is not an exemption. This documented educational reproducer supplies no deployment suitability, bias/safety assessment, calibrated accuracy or legal clearance; no surveillance, face recognition, consequential or automatic decisions.

  • Architecture accounting gives 427,944,193 scalar parameters and 1,711,776,772 bytes if all are FP32; this source-derived parameter-storage estimate is not observed checkpoint bytes, total resident RAM, peak or fit. Native reader architecture checks must pass.
  • 32 GiB RAM / 40 GiB disk / four threads are reused planning allocations, not measured minima. Native JIT and eager state may coexist during loading; tokenizer, two image tensors, dependency environment, buffers and OS add unknown overhead.
  • The native serialized checkpoint size is unknown; no HEAD or body was requested. Separate HF serialization metadata is not substituted for this native artifact.

One-time setup and hardware

hardware
Not applicable — AWS hardware acquisition is included in compute rental; no purchased GPU required. Any separate hardware cost is not applicable.
AWS hardware acquisition is included in compute rental; no purchased GPU required. Any separate hardware cost is not applicable. Tax: unknown.
setup
Unknown — Initial provisioning/build time and labor cost are unknown.
Initial provisioning/build time and labor cost are unknown. Tax: unknown.

Recurring costs

compute
$0.26 / hour
AWS public us-east-1 Linux On-Demand rate USD 0.2646 per billed instance-hour, no paid preinstalled software. Eight hours USD 2.1168; 24 hours USD 6.3504 compute. Idle running hours bill. Storage, egress, tax and administration separate; no Spot/reservation/discount assumed. Capacity/quota unverified. Region: us-east-1. SKU: r7i.xlarge Linux On-Demand. Tax: excluded. Price dated Oct 15, 2026. Price source
storage
$0.08 / GB month
US East (N. Virginia) gp3 USD 0.08 per GB-month; AWS defines GB as 1024^3 bytes. Selected 40 GiB root volume is USD 3.20 per full month, prorated by provisioned duration. Baseline 3000 IOPS / 125 MB/s; no extras assumed. Retained snapshots/resources separate; storage persists after instance stop. Tax excluded. Region: us-east-1. SKU: EBS gp3 baseline 3000 IOPS / 125 MB/s. Tax: excluded. Price dated Oct 16, 2026. Price source
egress
Unknown — Data transfer price, allowances and traffic volume are unknown.
Data transfer price, allowances and traffic volume are unknown. Tax: unknown.
administration
Unknown — Maintenance labor rate and hours are unknown.
Maintenance labor rate and hours are unknown. Tax: unknown.

Install the runtime

  1. 1. Create the pinned CPU research environment

    Install hashed official CPU wheels and exact native CLIP source. CLIP dependencies/transitive packages resolve at installation; save pip freeze and stop on pip check errors. This is documented compatibility, not an executed environment. The source package uses the same accepted CPU stack as the B32 guide; changing native architecture is verified by explicit reader loading/shape guards, not inferred execution.

    Command
    set -e
    sudo apt-get update
    sudo apt-get install -y python3.12 python3.12-venv git curl ca-certificates openssl
    mkdir -p "$HOME/clip336-research/models" "$HOME/clip336-research/fixture"
    cd "$HOME/clip336-research"
    python3.12 -m venv .venv
    .venv/bin/python -m pip install "https://download.pytorch.org/whl/cpu/torch-2.6.0%2Bcpu-cp312-cp312-linux_x86_64.whl#sha256=59e78aa0c690f70734e42670036d6b541930b8eabbaa18d94e090abf14cc4d91" "https://download-r2.pytorch.org/whl/cpu/torchvision-0.21.0%2Bcpu-cp312-cp312-linux_x86_64.whl#sha256=d6874431e678ba107b60a83f255c33f3755f06bad587b1b919aa514ec325dcd8"
    git clone https://github.com/openai/CLIP.git native-clip
    git -C native-clip checkout --detach d05afc436d78f1c48dc0dbf8e5980a9d471f35f6
    .venv/bin/python -m pip install ./native-clip
    .venv/bin/python -m pip check
    .venv/bin/python -m pip freeze > resolved-environment.txt

    Expected result: Exact checkout and CPU wheel hashes resolve; pip check passes and actual environment is recorded. No GPU driver required.

Download the model

  1. 1. Verify the exact native 336px checkpoint and packaged vocabulary

    Only the reader performs this download. The expected digest is literally the parent path of the pinned native OpenAI URL. Exact native file size remains unknown here; no weight body, HEAD or range was requested. Verify complete bytes before native import/load; do not use a similarly named HF or 224px artifact.

    Command
    set -e
    cd "$HOME/clip336-research"
    curl --fail --location --output models/ViT-L-14-336px.pt 'https://openaipublic.azureedge.net/clip/models/3035c92b350959924f9f00213499208652fc7ea050643e8b385c2dac08641f02/ViT-L-14-336px.pt'
    sha256sum --check <<'SHA256'
    3035c92b350959924f9f00213499208652fc7ea050643e8b385c2dac08641f02  models/ViT-L-14-336px.pt
    924691ac288e54409236115652ad4aa250f48203de50a9e4722a6ecd48d6804a  native-clip/clip/bpe_simple_vocab_16e6.txt.gz
    SHA256

    Expected result: Both complete hash checks report OK; stop on mismatch. The reader-generated fixtures are created later, with no remote media download or invented publisher fixture digest.

Configure

  1. 1. Create a private research key

    Create a local service key only when absent; preserve existing access and do not print or share it. This is not a provider API key.

    Command
    set -e
    cd "$HOME/clip336-research"
    umask 077
    if [ ! -e .api-key ]; then openssl rand -hex 32 > .api-key; fi
    test -s .api-key || { echo "Restore empty key before continuing"; exit 1; }
    chmod 600 .api-key

    Expected result: Private nonempty .api-key exists; existing key preserved.

  2. 2. Create the native paired-encoder adapter

    Reader-authored code verifies the trusted native checkpoint digest before native imports, loads the exact local file with native jit=False CPU handling and checks full architecture/dtype/finite parameters. It creates two original RGB geometry fixtures and validates native preprocessing/text lengths. This is not publisher server code.

    Command
    set -e
    cd "$HOME/clip336-research"
    cat > clip_research.py <<'PYCORE'
    """Reader-authored CLIP native336 fixed paired-image/text research; not publisher server."""
    import hashlib,hmac,json,math,pathlib
    from http.server import BaseHTTPRequestHandler,HTTPServer
    ROOT=pathlib.Path(__file__).resolve().parent
    PORT=8998
    MODEL_SHA='3035c92b350959924f9f00213499208652fc7ea050643e8b385c2dac08641f02'
    LABELS=['a red rectangle on a white background','a blue circle on a white background']
    
    def validate_result(result):
        if type(result)is not dict or set(result)!={'cosine','logits','token_counts'}:raise ValueError('result_schema')
        counts=result['token_counts']
        if type(counts)is not list or len(counts)!=2 or any(type(x)is not int or not 2<=x<=77 for x in counts):raise ValueError('token_counts')
        for name in ['cosine','logits']:
            matrix=result[name]
            if type(matrix)is not list or len(matrix)!=2:raise ValueError('matrix_shape')
            for row in matrix:
                if type(row)is not list or len(row)!=2 or any(type(x)not in(int,float)or not math.isfinite(x)for x in row):raise ValueError('nonfinite_or_shape')
                if name=='cosine'and any(not -1.00001<=x<=1.00001 for x in row):raise ValueError('cosine_range')
        return {'fixture':'author-shapes-v1','variant':'ViT-L/14@336px','labels':LABELS,'fixture_names':['red-rectangle','blue-circle'],'text_tokens_including_bos_eos':counts,'padded_text_shape':[2,77],'image_shape_per_call':[1,3,336,336],'image_embedding_shape_per_call':[1,768],'text_embedding_shape':[2,768],'vision_positions_per_image':577,'cosine':result['cosine'],'logits':result['logits'],'highest_labels':[LABELS[max(range(2),key=lambda i:row[i])]for row in result['logits']],'calibrated':False,'generated_text_tokens':None}
    
    def make_encoder():
        artifact=ROOT/'models/ViT-L-14-336px.pt'
        h=hashlib.sha256()
        with artifact.open('rb')as f:
            for block in iter(lambda:f.read(1048576),b''):h.update(block)
        if h.hexdigest()!=MODEL_SHA:raise RuntimeError('checkpoint_hash')
        # Native imports are only in the reader-run path, after trusted artifact verification.
        import torch,clip
        from PIL import Image,ImageDraw
        from clip.simple_tokenizer import SimpleTokenizer
        torch.set_num_threads(4)
        model,preprocess=clip.load(str(artifact),device='cpu',jit=False)
        model=model.float().eval()
        if model.visual.input_resolution!=336 or tuple(model.visual.conv1.kernel_size)!=(14,14):raise RuntimeError('variant_dimensions')
        if list(model.visual.positional_embedding.shape)!=[577,1024]or len(model.visual.transformer.resblocks)!=24:raise RuntimeError('vision_architecture')
        if model.context_length!=77 or list(model.text_projection.shape)!=[768,768]:raise RuntimeError('text_architecture')
        if any(p.device.type!='cpu'or p.is_floating_point()and p.dtype!=torch.float32 for p in model.parameters()):raise RuntimeError('cpu_fp32')
        if any(not torch.isfinite(p).all()for p in model.parameters()):raise RuntimeError('nonfinite_weights')
        tokenizer=SimpleTokenizer();counts=[len(tokenizer.encode(x))+2 for x in LABELS]
        tokens=clip.tokenize(LABELS,context_length=77,truncate=False)
        if list(tokens.shape)!=[2,77]or any(not 2<=n<=77 for n in counts):raise RuntimeError('text_budget')
        folder=ROOT/'fixture';folder.mkdir(exist_ok=True);images=[]
        # Original RGB images made by the reader; no downloaded media or external rights.
        for name in ['red-rectangle','blue-circle']:
            im=Image.new('RGB',(336,336),(255,255,255));draw=ImageDraw.Draw(im)
            if name=='red-rectangle':draw.rectangle((56,104,280,232),fill=(220,30,30))
            else:draw.ellipse((72,72,264,264),fill=(30,70,220))
            im.save(folder/(name+'.png'))
            image=preprocess(im).unsqueeze(0)
            if list(image.shape)!=[1,3,336,336]or not torch.isfinite(image).all():raise RuntimeError('preprocess')
            images.append(image)
        def encode():
            with torch.inference_mode():
                t=model.encode_text(tokens).float()
                if list(t.shape)!=[2,768]or not torch.isfinite(t).all()or (t.norm(dim=-1)<=0).any():raise RuntimeError('text_features')
                t=t/t.norm(dim=-1,keepdim=True);cosine=[];logits=[]
                for image in images:
                    i=model.encode_image(image).float()
                    if list(i.shape)!=[1,768]or not torch.isfinite(i).all()or (i.norm(dim=-1)<=0).any():raise RuntimeError('image_features')
                    i=i/i.norm(dim=-1,keepdim=True);c=i@t.T;l=model.logit_scale.exp()*c
                    if not torch.isfinite(c).all()or not torch.isfinite(l).all():raise RuntimeError('similarity')
                    cosine.append(c[0].tolist());logits.append(l[0].tolist())
            return {'cosine':cosine,'logits':logits,'token_counts':counts}
        return encode
    
    PYCORE

    Expected result: Core adapter source written. No model load, tokenizer execution or fixture generation occurs until the reader starts it.

  3. 3. Complete and verify the private transport

    Append the strict serial loopback transport, then verify the exact complete wrapper. Only the fixed fixture identifier is accepted; inputs cannot request files, URLs, labels or model selections.

    Command
    set -e
    cd "$HOME/clip336-research"
    cat >> clip_research.py <<'PYHTTP'
    def create_server(encoder, key, port=PORT):
        if not isinstance(key, str) or len(key) != 64 or any(c not in '0123456789abcdef' for c in key):
            raise ValueError('key_format')
    
        class Handler(BaseHTTPRequestHandler):
            def setup(self):
                super().setup()
                self.connection.settimeout(5)
    
            def log_message(self, *_):
                pass  # Do not log Bearer keys or request bodies.
    
            def reply(self, status, obj):
                data = json.dumps(obj, allow_nan=False, separators=(',', ':')).encode()
                self.send_response(status)
                self.send_header('Content-Type', 'application/json')
                self.send_header('Content-Length', str(len(data)))
                self.send_header('Connection', 'close')
                self.end_headers()
                self.wfile.write(data)
                self.close_connection = True
    
            def authorized(self):
                values = self.headers.get_all('Authorization', [])
                return len(values) == 1 and hmac.compare_digest(values[0].encode(), ('Bearer ' + key).encode())
    
            def do_GET(self):
                if not self.authorized():
                    return self.reply(401, {'error': 'unauthorized'})
                if self.path != '/health':
                    return self.reply(404, {'error': 'not_found'})
                return self.reply(200, {'ready': True, 'text_context_per_label': 77,
                                        'generated_text_tokens': None})
    
            def do_POST(self):
                if not self.authorized():
                    return self.reply(401, {'error': 'unauthorized'})
                if self.path != '/v1/clip-research':
                    return self.reply(404, {'error': 'not_found'})
                if self.headers.get('Transfer-Encoding') is not None:
                    return self.reply(400, {'error': 'transfer_encoding_unsupported'})
                lengths = self.headers.get_all('Content-Length', [])
                if len(lengths) != 1:
                    return self.reply(411, {'error': 'content_length_required'})
                raw = lengths[0]
                if not raw or len(raw) > 4 or any(c not in '0123456789' for c in raw):
                    return self.reply(413, {'error': 'invalid_or_excessive_length'})
                n = int(raw)
                if n < 1 or n > 256:
                    return self.reply(413, {'error': 'body_limit'})
                if self.headers.get_content_type() != 'application/json':
                    return self.reply(415, {'error': 'json_required'})
                try:
                    body = self.rfile.read(n)
                except (TimeoutError, OSError):
                    return self.reply(408, {'error': 'body_timeout'})
                if len(body) != n:
                    return self.reply(400, {'error': 'incomplete_body'})
                try:
                    def unique(pairs):
                        obj = {}
                        for k, v in pairs:
                            if k in obj:
                                raise ValueError('duplicate_key')
                            obj[k] = v
                        return obj
                    request = json.loads(body.decode('utf-8'), object_pairs_hook=unique,
                                         parse_constant=lambda _: (_ for _ in ()).throw(ValueError('constant')))
                except (ValueError, UnicodeError, RecursionError):
                    return self.reply(400, {'error': 'invalid_json'})
                if type(request) is not dict or request != {'fixture': 'author-shapes-v1'}:
                    return self.reply(400, {'error': 'fixed_fixture_required'})
                try:
                    result = validate_result(encoder())
                except Exception:
                    return self.reply(500, {'error': 'predictor_or_mask_failure'})
                return self.reply(200, result)
    
        return HTTPServer(('127.0.0.1', port), Handler)
    
    
    if __name__ == '__main__':
        secret = (ROOT / '.api-key').read_text().strip()
        encoder = make_encoder()
        with create_server(encoder, secret) as server:
            server.serve_forever()
    PYHTTP
    .venv/bin/python -m py_compile clip_research.py
    sha256sum --check <<'SHA256'
    806f8f79957e3fed222aa271651c12a473be3b3e92aa70daaa573c399c8fc3bd  clip_research.py
    SHA256

    Expected result: Python syntax and exact whole-wrapper hash verify without native execution.

Start the model

  1. 1. Start the bounded research reproducer

    Run from the dedicated workspace. The native loader rebuilds the complete checkpoint and loads state_dict with strict default checking, then converts to CPU float32/eval. Startup requires vision resolution 336, patch 14, 577 visual positions, 24 vision blocks and 768 projections; unexpected variants stop. Two images are encoded serially, one request at a time.

    Command
    set -e
    cd "$HOME/clip336-research"
    .venv/bin/python clip_research.py

    Expected result: Only after the reader completes the unexecuted startup checks does loopback 127.0.0.1:8998 serve health. Actual fit, loading success and native results are not claimed.

Connect to your endpoint

http://127.0.0.1:8998/v1/clip-research

VM loopback only. With existing SSH access, optional tunnel: ssh -N -L 8998:127.0.0.1:8998 USER@VM_IP. Keep EC2 service port 8998 closed; shown checks run on server.

Access: loopback. Use the private Bearer key for health and the fixed research request. Send a JSON object with fixture set to author-shapes-v1. The response has two original image names, two fixed English labels, per-label token counts, shape metadata and two-by-two relative similarity matrices. No arbitrary files, URLs, uploads or new labels.

Verify the setup

  1. 1. Inspect finite paired similarities against the actual original images

    Request the fixed experiment from a second server terminal. Check exact labels/fixtures, 77-position padded text, per-label counts including BOS/EOS, serial image shape 1 × 3 × 336 × 336, 768-dimensional projections and two-by-two finite matrices. Open both generated images and inspect whether matched descriptions rank above mismatched descriptions. Record failures and matrix values without requiring a promised ordering or inventing an accuracy result. Geometry is a deliberately simple controlled RGB input, not a natural-image dataset or sufficient in-domain/bias validation.

    Command
    set -e
    cd "$HOME/clip336-research"
    CLIP_RESEARCH_KEY="$(cat .api-key)"
    curl --fail http://127.0.0.1:8998/health -H "Authorization: Bearer $CLIP_RESEARCH_KEY"
    curl --fail http://127.0.0.1:8998/v1/clip-research -H "Authorization: Bearer $CLIP_RESEARCH_KEY" -H 'Content-Type: application/json' -d '{"fixture":"author-shapes-v1"}' -o result.json
    curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8998/health
    unset CLIP_RESEARCH_KEY
    .venv/bin/python - <<'PYVERIFY'
    import json,math
    d=json.load(open('result.json'));labels=['a red rectangle on a white background','a blue circle on a white background']
    assert d['labels']==labels and d['fixture_names']==['red-rectangle','blue-circle']
    assert d['padded_text_shape']==[2,77] and d['image_shape_per_call']==[1,3,336,336]
    assert d['text_embedding_shape']==[2,768] and d['image_embedding_shape_per_call']==[1,768]
    assert d['vision_positions_per_image']==577 and d['generated_text_tokens']is None and d['calibrated']is False
    assert len(d['text_tokens_including_bos_eos'])==2 and all(type(x)is int and 2<=x<=77 for x in d['text_tokens_including_bos_eos'])
    for name in ['cosine','logits']:
     assert len(d[name])==2 and all(len(r)==2 and all(type(x)in(int,float)and math.isfinite(x)for x in r)for r in d[name])
    assert d['highest_labels']==[labels[max(range(2),key=lambda i:r[i])]for r in d['logits']]
    print('Open fixture/red-rectangle.png and fixture/blue-circle.png. Record matched versus mismatched similarities; no ordering or quality guarantee.')
    PYVERIFY

    Expected result: Authorized health and research JSON follow the exact schema; missing authorization returns 401. Structural checks pass only after actual reader execution. Human inspection records rankings and mistakes, without calibration, general accuracy or deployment approval.

Performance evidence

No compatible measurement available. Documented support and estimated memory do not establish response speed.

Limits and troubleshooting

  • Native CLIP model card places any deployed use, commercial or not, outside scope; private/cloud location is not an exemption. The educational fixed-input protocol reproducer does not grant deployment suitability. Non-deployed use still needs thorough fixed-taxonomy in-domain testing; no automatic, consequential, surveillance or face-recognition use.
  • ViT-L/14@336px is a distinct higher-resolution native variant in frozen generic CLIP family. Native expected hash comes from the exact pinned runtime URL; no B32, 224px or HF byte equivalence is claimed. Exact native serialized size is unknown without prohibited body/HEAD/range retrieval.
  • The full model includes a 24-block width-1024 visual encoder and 12-block width-768 text encoder, projected to 768 dimensions. The 336px/14px patch grid gives 576 patches plus one class position. This differs from the B32 guide; no sibling fit, speed or quality transfer.
  • 77 is the native per-label text length including BOS/EOS. It is separate from the 577 visual sequence and 768 embedding dimension; no text generation, chat template, autoregressive K/V cache or decoded output applies.
  • Both original RGB geometry images are generated by the reader; no media was downloaded/generated by this author. Their descriptive labels provide a controlled matched/mismatched comparison, not a representative natural-image dataset. No ranking or score is promised.
  • Embeddings are checked finite/nonzero before normalization; cosine/logits must be finite and correctly shaped. Learned-scale logits and highest-label ranking are relative to two labels, not calibrated probabilities, semantic truth or general recognition accuracy.
  • 32 GiB RAM, 40 GiB disk and four threads are chosen allocations, not minimum requirements or proven fit. Architecture-derived FP32 parameter storage is about 1.71 GB; load-time JIT/eager copies, attention, buffers, environment and OS add unmeasured overhead.
  • The native trusted checkpoint loader first tries torch.jit.load and has a state-dict fallback. Never load arbitrary PyTorch files or relax state-key checking; complete publisher hash verification is mandatory before native import/load.
  • Strict private serial HTTPServer bounds fixed request body, socket read, labels, image count and output matrices. It has no native inference deadline, public TLS or multiuser resilience. A private VM endpoint remains subject to the publisher research-use qualification.
  • Exact direct CPU wheels/native source are pinned as in the accepted stack; transitive/system dependencies resolve at reader install and must be saved with pip freeze. No model import, native tokenizer, preprocessing, load or inference was executed; fake tests only validate transport/output boundaries.
  • Other native variants, arbitrary image search, larger taxonomies, alternative backends/OS and full family scope remain unqualified. This pair is not a final guide denominator.
Hash, architecture, dtype or state-key failure
Stop. Restore the exact native 336px checkpoint/source/BPE and CPU environment. Do not substitute the 224px variant, HF weights or smaller encoders, relax strict state checks or silently truncate text.
Wrong or tied relative rankings
Open both original fixture images and inspect the two fixed descriptions. Record cosine/logit matrices and matched versus mismatched outcomes honestly. No exact order, accuracy, calibration or natural-image generalization is promised.
401 or rejected request
Use the stable private key and exact author-shapes-v1 fixture JSON. Arbitrary file/URL inputs, uploads, custom labels and model changes are rejected.
Native CPU load or memory failure
Stop and record exact dependency versions, available memory and errors. Allocation is unmeasured; do not infer CPU fit from source-only fake tests or delete model components to force a smaller workflow.

Stop the model

  1. 1. Stop the experiment

    Press Ctrl+C in the server terminal and unset keys in client shells. Close SSH tunnel; stopping Python does not stop VM billing.

    Command
    set -e
    unset CLIP_RESEARCH_KEY

    Expected result: Python research harness stops; loopback port 8998 no longer serves.

Uninstall

  1. 1. Remove dedicated experiment files

    Preserve wanted logs/results first and confirm the dedicated path. Shared system packages may remain.

    Command
    set -e
    rm -r -- "$HOME/clip336-research"

    Expected result: Dedicated checkpoint, native source, virtualenv, two original fixtures, result JSON, wrapper and private key removed; shared system packages remain.

Shut down cloud resources

  1. 1. End cloud billing resources

    In EC2 us-east-1, stop for later reuse or terminate this exact VM. Review Delete on termination for its root volume. Delete unwanted detached EBS volumes, snapshots and reserved/Elastic/public IP resources. Stopped VM storage and retained resources may still bill. Check Bills/Cost Explorer later for final usage.

    Expected result: Exact instance is stopped/terminated as intended; no unwanted attached/retained billed resources remain. Instance compute stops only after its lifecycle transition, not when the Python service stops.

Sources and verification

Sources checked Oct 17, 2026. Verification source

Compare this configuration

Benchmarks

Performance scores for CLIP across standard benchmarks.

ImageNet zero-shot top-1official-openai-clip-paper · Jan 2021
76.2

Pricing and access

Open-source research model/checkpoints; no hosted API price is specified in the GitHub repository.

OpenAI logo
OpenAIai lab

Creating safe AGI that benefits all of humanity

249 Tools58 MCP Servers14 ModelsFounded 2015San Francisco, CA
View full profile

Tools by OpenAI

Other AI tools from the same organization.

AI Models by OpenAI

AI models from the same organization.

ModelContext WindowPrice (In / Out per M)
GPT-6.1 SolCurrent1.1M$2.00 / $10.00
GPT-6 SolCurrent1.1M$2.00 / $10.00
GPT-6 LunaCurrent1.1M$0.10 / $0.50
GPT-5.6 LunaCurrent1.1M$0.20 / $1.20
GPT-5.6 TerraCurrent1.1M$2.00 / $12.00
GPT-5.6 SolCurrent1.1M$4.00 / $20.00

MCP Servers by OpenAI

Connect this tool to AI assistants via the Model Context Protocol.

Related News

Latest coverage and updates.