aifeng.space Blog

website·Indexed 31 days ago

https://www.aifeng.space/

A personal blog featuring technical tutorials and reflections on cognitive growth. Topics include OpenAI function calling, Git troubleshooting (invalid sha1 pointer), the use of Discourse Graph in Roam Research, and memory techniques such as the Memory Palace.

Tokens
4.9K
Snippets
4
Records
26
Agent score
49%

What's inside aifeng.space

  1. Understand OpenAI Function Calling for structured data

    OpenAI's function calling allows ChatGPT to generate parameters in a structured data type (stable JSON output) to interact with custom functions. This enables the model to extract specific function arguments from natural language, providing a more flexible way to integrate LLMs with external tools and APIs.
  2. Understand the purpose and behavior of OpenAI Function Calling

    OpenAI's function calling allows ChatGPT to generate structured data (JSON) to interact with custom functions. Its primary role is to extract specific function parameters from natural language, enabling developers to call their own code without passing the actual implementation to the model.

    Key behavioral notes:

    • It is not a direct 'chain' of execution; the model identifies the need for a function and provides the arguments, but the developer must execute the function and pass the result back to the model.
    • Completing a single user request may require multiple round-trips (calls) depending on the number of steps needed.
    • In GPT-3.5, there can be instability in matching similar functions or maintaining consistent JSON structures during complex multi-step calls.
  3. Understand the Method of Loci (Memory Palace)

    The Memory Palace (Method of Loci) is a mnemonic technique that involves associating information with specific physical locations in a familiar environment. By imagining yourself walking through this space and 'placing' information at specific landmarks, you create a spatial map that strengthens recall and cognitive organization.
  4. Advantages of bidirectional linking in note-taking

    Bidirectional linking (bi-links) provides several functional advantages over traditional single-link or folder-based note-taking systems, particularly when notes are managed at the 'information block' level:

    1. Reverse Thinking & Traceability: Bi-links automatically notify the user when the same information element is used elsewhere (e.g., via 'Linked/Unlinked References'), enabling the discovery of connections that would be missed in traditional notes.
    2. Flexible Management: Combines hierarchical folder management with more fluid writing via bi-links and nested tags, allowing for organic growth of content without rigid pre-structuring.
    3. Aggregated Search: Enables precise querying from a keyword page down to a specific keyword block.
    4. Visual Knowledge Mapping: Tools like org-roam or RoamResearch allow for the visualization of connections between notes, which is useful during the expansion phase of holistic learning.
    5. Reduced Friction: Users can focus on application scenarios rather than categorization, leading to a smoother writing experience and less worry about missing information.
    6. Information Compression & Reuse: Supports fragmented note-taking with bidirectional previews, allowing users to keep original text concise while expanding details via links without bloating the primary document.
    7. Global Updates: A single change to a linked block propagates across all references, eliminating the need for manual updates in multiple locations.
    8. Bottom-Up Synthesis: Encourages a 'Lego-like' building process where output is accumulated from small, connected pieces rather than written as a single, monolithic task.
  5. Implement the Feynman Technique for learning and knowledge retention

    The Feynman Technique is a method of learning by explaining a concept in the simplest terms possible to ensure deep understanding and the ability to create cross-scenario associations. The process consists of four steps:

    1. Teach it to a child: Explain the concept using simple language. If you struggle to explain a part, it identifies a gap in your own understanding.
    2. Review: Return to the source material to fill gaps. Use tools like mind maps to create associations and keywords rather than simple lists.
    3. Simplify and Organize: Refine the language for precision and clarity. Use a Q&A format or bulleted notes to break complex information into smaller, digestible units (minimum information units) rather than long lists.
    4. Transmit (Optional): Effectively communicate the knowledge to others. Writing a blog is a recommended way to decompose and reorganize thoughts for this purpose.
  6. Implement Memory Palace for long-term learning and metacognition

    To maximize the effectiveness of a Memory Palace, combine the technique with self-monitoring, adjustment, and evaluation to develop metacognitive skills. Integrate this into daily life by associating new knowledge with existing information and assigning it to specific 'rooms' within the palace. Over time, increasing the complexity and detail of the palace expands cognitive capacity and deepens insight into the learned material. This internal memory system can be complemented by external systems, such as Zettelkasten (slip-box) note-taking, to create a comprehensive internal and external brain.
  7. Increase Memory Palace capacity using numeric codes

    To increase the amount of information stored in a single spatial area, combine the Memory Palace with numeric codes. Since humans typically recall sequences in groups (e.g., intervals of 1, 5, or 10), you can convert numbers into concrete objects and place them at key intervals. This expands the number of 'memory pegs' available. As your understanding of a concept evolves, you should iterate and replace the existing imagery with more accurate representations, which facilitates deep thinking.
  8. Implement a decoupled Zettelkasten workflow in Roam Research

    To reduce cognitive load and ensure notes meet the 'minimum information principle,' separate the process of standardized storage from the creation of atomized cards. This prevents the user from relying on the context of the source text when reviewing, forcing a more rigorous retrieval and synthesis process.

    Key Workflow Components:

    • Standardized Storage: Focuses on clear sourcing and traceability; allows for redundancy and detailed process data.
    • Atomized Cards: Focuses on minimizing cognitive burden; hides distracting source context to determine if a card is ready for the 'Evergreen' (permanent) box.
    • Tagging Strategy: Use 'Big Words' (Uppercase) for broad themes, projects, and domains, and 'Small Words' (Lowercase) for specific tasks, usage scenarios, and associations.
  9. Configure third-party domain DNS for Sanfengyun

    If you purchased a domain from a third-party provider (e.g., Alibaba Cloud) but are using Sanfengyun hosting, follow these steps to resolve the domain:

    1. In the Sanfengyun 'Non-filing Service' (免备案服务) section, submit your purchased domain and copy the provided CNAME alias address.
    2. In your domain provider's DNS management console, add a CNAME record. The '@' record is mandatory; the 'www' record is optional for subdomains.
    3. Verify that the DNS resolution is complete using a tool like the Alibaba Cloud Website Operation and Maintenance Detection Platform.
    4. Once resolved, go to the WordPress Dashboard -> General Settings and update the site domain to your purchased domain, then save the changes.
  10. Implement a single function call with OpenAI ChatCompletion

    To implement a function call, you must define the function's schema, handle the model's request for parameters, execute the local function, and then send the result back to the model for a final natural language response.
    import openai
    import json
    
    # 1. Define the function description for the API
    function_descriptions = [
        {
            "name": "get_student_score",
            "description": "Get the student score by given his or her name",
            "parameters": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string",
                        "description": "The student's name",
                    }
                },
                "required": ["name"],
            }
        }
    ]
    
    # 2. Define the actual execution function
    def get_student_score(name):
        """Get the student score by given his or her name"""
        # Mock data
        SCORES = {"Lucy": 60}
        score = {
            "name": name,
            "score": SCORES.get(name, "unknown")
        }
        return json.dumps(score)
    
    # 3. First call: Extract parameters from user query
    user_query = "What's the performance of Lucy in the school this year?"
    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo", # Example model
        messages=[{"role": "user", "content": user_query}],
        functions=function_descriptions,
        function_call="auto"
    )
    
    ai_response_message = response["choices"][0]["message"]
    
    # Extract the argument (e.g., 'Lucy')
    arguments = json.loads(ai_response_message['function_call']['arguments'])
    name = arguments.get("name")
    
    # 4. Execute the local function
    function_response = get_student_score(name)
    
    # 5. Second call: Provide the function result to get a final natural language answer
    second_response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=[
            {"role": "user", "content": user_query},
            ai_response_message,
            {
                "role": "function",
                "name": "get_student_score",
                "content": function_response,
            },
        ],
    )
    
    print(second_response['choices'][0]['message']['content'])
    # Output: Lucy has achieved a score of 60 this year.
  11. Use Memory Palaces to enhance cognitive processing and creativity

    The Memory Palace technique is not limited to simple facts; it can be used to integrate diverse types of information and complex themes through creative imagination. This process improves cognitive flexibility and information processing by requiring the user to analyze, categorize, and organize information to link it with existing knowledge systems. Regular practice in building these palaces fosters deeper understanding and a more comprehensive ability to synthesize information when facing complex problems.