Created at 170623
# [Anonymous feedback](https://www.admonymous.co/louis030195)
# [[Epistemic status]]
#shower-thought
Last modified date: 170623
Commit: 0
# Related
- [[Karl Popper]]
# Applied Karl Popper Epistemology
1. Define the problem or question to be addressed under the scope of epistemology
2. Formulate a tentative hypothesis or conjecture as a potential solution to the problem
3. Attempt to refute the hypothesis through empirical observation, experimentation, or logical argumentation
4. IF the hypothesis holds up against these tests and there is no evidence to disprove it,
THEN tentatively accept it as a current best explanation, keeping in mind that future evidence may overturn the hypothesis
5. ELSE IF the hypothesis is refuted by evidence,
THEN go back to step 2 and develop a new hypothesis based on the results of the refutation
6. Repeat steps 3-5 with each new hypothesis in a continuous cycle, aiming to minimize errors and come closer to truth over time
7. Integrate the surviving hypothesis into the existing body of knowledge, allowing for them to be critically assessed and built upon by others
8. Maintain a commitment to the open society, fostering a spirit of critical rationalism, whereby all ideas and theories are open to scrutiny, criticism, and potential falsification
9. Recognize that absolute certainty is unattainable and that knowledge is always provisional and open to change in light of new evidence or criticism
10. Continue this process indefinitely, as the pursuit of knowledge and truth is an ongoing endeavor
```js
// WARNING: this is extremely experimental code and is likely not following rigorously enough the Tree Of Thoughts agent paper.
// import embedbase
const { createClient } = require('embedbase-js');
// initialize client
const embedbase = createClient(
// this uses the hosted version of embedbase
'https://api.embedbase.xyz',
// Go to https://app.embedbase.xyz/signup to get your own api key
'...');
const epistemologicalComments = require("./karl-popper-agent.json").comments;
const getContexts = async (problem) => {
const searchResults = await embedbase.internetSearch(problem);
return searchResults.map((result) => result.snippet);
};
const treeOfThoughts = async (comment) => {
const problem = `Is the statement "${comment.text}" true?`;
const hypothesis = `The statement "${comment.text}" is true.`;
const counterHypothesis = `The statement "${comment.text}" is false.`;
const MAX_DEPTH = 3;
const NUM_CANDIDATES = 5;
const THRESHOLD = 0.6;
const contexts = await getContexts(problem);
async function getTruthValue(node, depth) {
if (depth >= MAX_DEPTH) return node.value;
const prompt = `Given the following context: ${contexts.join(" ")} Which of the following statements has a higher probability of being true: "${hypothesis}" or "${counterHypothesis}"?`;
const candidates = [];
for (let i = 0; i < NUM_CANDIDATES; i++) {
candidates.push((await embedbase.generate(prompt).get()).join(""));
console.log(`Generated candidate: ${candidates[i]}`);
}
const supportingEvidence = candidates.filter((c) => c.includes(hypothesis)).length;
const supportingRatio = supportingEvidence / NUM_CANDIDATES;
if (supportingRatio > THRESHOLD) {
node.value = "true";
} else if (supportingRatio < 1 - THRESHOLD) {
node.value = "false";
} else {
node.value = "uncertain";
node.children.push({ text: hypothesis, value: null, children: [] });
node.children.push({ text: counterHypothesis, value: null, children: [] });
for (const child of node.children) {
await getTruthValue(child, depth + 1);
}
}
return node.value;
}
const rootNode = { text: problem, value: null, children: [] };
console.log(`Generating thoughts for problem: "${problem}"`);
return await getTruthValue(rootNode, 0);
};
const evaluateComments = async (comments) => {
for (const comment of comments) {
const truthValue = await treeOfThoughts(comment);
comment.truth = truthValue;
console.log(`Truth value for comment "${comment.text}" is ${comment.truth}`);
}
return comments;
};
evaluateComments(epistemologicalComments).then((updatedComments) => {
console.log(updatedComments.map((comment) => ({ id: comment.id, truth: comment.truth })));
});
```