QA AND TEST AUTOMATION · PART 11 · AI TOOLS FOR TESTERS · TOOLS · 104 OF 112

Local AI Models for Testing With Private Data

When test data, logs or code cannot leave your machine, run the model locally. Measured on a 16 GB Apple M5 laptop with Ollama: llama3.2:3b is a 2 GB download, used 7.5 GB of memory with its 32,768-token context, answered at 33 to 37 tokens a second, and took 1.4 s longer on a cold start. What local models are good enough for, and how to mask secrets before anything reaches a cloud model.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 67
  63. 68
  64. 69
  65. 70
  66. 71
  67. 72
  68. 73
  69. 74
  70. 75
  71. 76
  72. 77
  73. 78
  74. 79
  75. 80
  76. 81
  77. 82
  78. 83
  79. 84
  80. 85
  81. 86
  82. 87
  83. 88
  84. 89
  85. 90
  86. 91
  87. 92
  88. 93
  89. 94
  90. 95
  91. 96
  92. 97
  93. 98
  94. 99
  95. 100
  96. 101
  97. 102
  98. 103
  99. 104
  100. 105
  101. 106
  102. 107
  103. 108
  104. 109
  105. 110
  106. 111
  107. 112
1 / 10

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Ollama
  • 2 GB download, 7.5 GB in memory
  • 33-37 tokens/s
  • good for drafts
  • mask before cloud, test the masker

Notes

Set it up

Ollama is the simplest way. Install it, pull a model, and it serves an HTTP API on your machine at port eleven four three four. Your scripts and tools call that address instead of a cloud service; that is how ShopRung's support chat, the judge and the triage experiments in this course ran. Other options exist, such as LM Studio and llama dot cpp, but the idea is the same.

Install and run
brew install ollama  (or the
  installer from ollama.com)
ollama pull llama3.2:3b
ollama run llama3.2:3b
API: http://localhost:11434
  /api/chat, /api/generate
ShopRung: SHOPRUNG_CHAT_MODEL=
  llama3.2:3b npm start

Measured

Real numbers from a sixteen gigabyte Apple M five laptop. The model has three point two billion parameters, compressed to four bits, a two gigabyte download. Loaded, it used seven and a half gigabytes, mostly for its thirty two thousand token context window. The first call took four point one seconds, one point four of them loading; warm calls took about three seconds for a hundred words of output, thirty three to thirty seven tokens a second.

llama3.2:3b, real numbers
parameters  3.2 billion
quantized   Q4_K_M
download    2.0 GB
in memory   7.5 GB, with a
            32,768-token context
cold call   4.1 s (1.4 s loading)
warm call   2.7 to 3.2 s for
            about 100 tokens
speed       33 to 37 tokens/s

Good enough?

Is a small local model good enough? From this course: it answered the support chat golden set well, thirty one of thirty six, but as a judge it only reached moderate agreement with humans, and it labelled eight of twelve failures correctly. Its test cases invented rules and none of its six pytest files ran as written. Good for drafts, summaries and classification with checks around it; not for unreviewed expected values or code.

llama3.2:3b, measured earlier
support chat golden set  31/36
as a judge: kappa 0.52
  (calibrated, vs humans)
failure triage            8/12
test cases: invented rules
pytest files: 0 of 6 ran
  as written
fine for: drafts, summaries,
  classification with checks

Choose

So decide per task and per kind of data. Local keeps data on the machine, has no token bill and works offline, but you get smaller models on your own hardware, and bigger local models need more memory and run slower. Cloud models are stronger and need no setup, but the data leaves, you pay per token, and the provider's terms apply. Many teams use both: local for anything sensitive, cloud for the rest.

Trade-offs
  • local: data stays, no token bill, works offline; smaller models, your hardware
  • cloud: stronger models, no setup; data leaves, per-token cost, provider terms
  • bigger local models need more memory and are slower
  • decide per task and data class

Mask first

When data must go to a cloud model, mask it first. We wrote a small script to redact tokens, emails and passwords, and ran it on the ShopRung trace from the coding agents episode. The first version caught the bearer token and the email, and missed the password, because the trace prints it on a different line than we assumed. After fixing the pattern, nothing was left. Test your masker like any other code, on real samples.

mask.py on a real trace dump
bearer token   1 → [TOKEN]
email          1 → [EMAIL]
password fill  0  ← missed!
  Fill "Alice123!"
fixed the pattern, ran again:
  password fill 1 →
  Fill "[PASSWORD]"
secrets left: 0

Rules

Write the rules down. Never send credentials, keys or real customer data. Use synthetic or masked test data. Use a local model for logs and traces from shared environments. Use only approved providers whose terms exclude training on your data. Give the masking script its own tests. And keep a record of what was sent, and where, so a leak can be traced.

Team rules
  • never: credentials, real customer data, keys
  • synthetic or masked test data
  • local model for logs and traces from shared envs
  • approved providers only, with no-training terms
  • the masker has its own tests
  • log what was sent, and where

Common mistakes

Mistakes. Assuming a small local model matches a large cloud one. Measuring speed on the first, cold call. Forgetting that the context window costs gigabytes of memory. Trusting a masking script nobody tested, like our first version. Sending real data just this once. And not pinning the model version, so results change when someone pulls an update.

Avoid these
  • assuming local = as good as a large cloud model
  • judging speed on a cold start
  • ignoring memory: the context window costs gigabytes
  • a masker nobody tested
  • real data "just this once"
  • no model version pinned

Say it like this

In the interview: sensitive logs and data go to a local model. On a sixteen gigabyte laptop, a three billion parameter model ran at about thirty five tokens a second, good enough for drafts, summaries and triage suggestions, not for unreviewed expected values. Anything sent to a cloud model is masked first, and the masking script has its own tests: our first version missed a password.

In the interview
  • "Sensitive logs and data go to a local model: on a 16 GB laptop
  • a 3B model ran at about 35
  • tokens a second. It is fine for drafts and triage suggestions, not for unreviewed expected
  • values. Anything sent to the cloud is masked first, and the masker has tests: ours missed
  • a password at first."

Interview questions

Q1Why use a local model in testing?

Sensitive logs, test data and code stay on your machine; there is no token bill and it works offline.

Q2How do you run one?

For example with Ollama: install, `ollama pull llama3.2:3b`, and call its HTTP API on localhost:11434.

Q3What did llama3.2:3b need on a 16 GB Apple M5?

A 2.0 GB download, 7.5 GB of memory with a 32,768-token context, about 3 s per 100-token answer when warm (33 to 37 tokens a second) and 1.4 s extra on a cold start.

Q4What is a small local model good enough for?

Drafts, summaries and classification with checks around them; in this course it reached 8 of 12 on triage and invented details in test cases and code.

Q5What is quantization?

Storing model weights with fewer bits (here 4-bit Q4_K_M) so the model is smaller and faster, at some cost in quality.

Q6What should be masked before using a cloud model?

Tokens, passwords, keys, emails and any customer data; test the masking script on real samples.

Q7Why test a masking script?

Formats surprise you: our first version missed a password that the trace printed on a different line.

Q8Local or cloud: how do you decide?

Per task and data class: local for sensitive data and cheap drafts, approved cloud providers with masked data for tasks that need a stronger model.