0% found this document useful (0 votes)
53 views30 pages

Swift Tasking

swift tasking

Uploaded by

MIghty Saitama
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views30 pages

Swift Tasking

swift tasking

Uploaded by

MIghty Saitama
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 30

Swift tasking

This project will focus on utilizing the Swift programming language,


where you will be asked to write prompts and their responses from scratch.
Here are the type of tasks you will be working on:

1. Coding Standard

2. Code Generation

3. Problem Reflection

4. Test Reasoning

5. Code Refactoring

6. Structure Data Generation

7. Coding Advanced

8. Retrieval Augmented Generation (RAG)

9. Test Generation

10. Bug Fixing

11. Solution Reasoning

You will create your prompts and responses for two different projects:

 🧼 Prompt + 🧽 Response - Single Turn

 Only 1 prompt and 1 response

 🧼 Prompt & 🧽 Response Multiturn

 3 different prompts and responses

The overall goal of this project is to develop creative, engaging


conversations, stories, and analyzes that are more human and engaging than
the best models on the market today. 🐝 🎉

Need Help?

1) Prompt + Response - Single turn


In this project, you are provided with a prompt type to write (Code
Generation, Problem Reflection, Test Reasoning, Code Refactoring, Structure
Data Generation, Retrieval Augmented Generation (RAG), Test Generation,
Bug Fixing, Solution Reasoning, Tool Use), and basic guidelines. You will write
a thoughtful, clear prompt that will generate an interesting, unique, and
useful response from an LLM.

Step 1: Be the user

Your prompt will be perfect and follow this structure:

 Clear Asks: Specific requests or tasks to be completed.

 Personal Perspective: The individual's viewpoint or situation.

 Context: Background information and circumstances surrounding the


request.

 Goal / Value: The desired outcome or benefit of fulfilling the request.

Step 2: Become the LLM

After writing your prompt, you will write a response to your prompt. The
response will also be completely perfect. If you were to send your ‘user
written prompt’ to an LLM and that LLM provided you with your written
response, you should be delighted. This response must be:

 Highly creative

 Neatly organized and easy to read

 Thoughtfully designed to be delightful to the reader

Your response needs to be better than the best LLM available (state-of-
the-art model: SOTA).To accomplish this:

 Review the Task Type: In the UI there will be a note indicating the
task type (Code Generation, Problem Reflection, Test Reasoning, Code
Refactoring, Structure Data Generation, Retrieval Augmented
Generation (RAG), Test Generation, Bug Fixing, Solution Reasoning, Tool
Use). Review the task-specific instructions for any clarifications.

 Use Perfect Spelling, Grammar, and Punctuation: In order to beat


SOTA, you will need to proofread your work and eliminate any
grammatical, spelling, punctuation, or other errors.

 Consider the User: Need to be sure that you respond to all of the
following questions:

 Would the response you created delight the user relative to the
prompt?

 Does it address the prompt completely?

 Does it understand the intention of the prompt?

An LLM is just a computer!! You’re a real person. Shouldn’t be too hard to


beat, right? 😤👊🤜 + 🤖 = 💥

Quick note: In some situations, you may also receive a pre-written prompt.
In this situation write the response to that prompt as if you were an LLM.

2) Prompt + Response - Multiturn

A Multi-turn conversation strings together multiple prompts and responses.


For example, a 3-turn conversation would look like:

 Prompt 1 / Response 1 ->

 Prompt 2 / Response 2 ->

 Prompt 3 / Response 3

 End of conversation

REMEMBER: In Multi-Turn conversations, there are multiple prompts and


responses, each prompt and response builds off the context provided in
the previous prompt and response. After the initial prompt and response, the
conversation continues with additional questions, clarifications, or responses,
ultimately forming an extended dialogue.

⚠️It’s extremely important to maintain continuity in the multi-turn


prompts. In case the task fails to fulfill this, - the task will receive
an automatic 1 or 2 ⚠️

 If the minimum number of turns is two or more, then your task


requires you to add the minimum number of turns.

 Every prompt after the first must relate to the category and
subcategory and continue a natural conversational flow as a follow-up
to the previous response.

Need Help?

Expected quality - Prompt

What should the perfect prompt structure be like?

 Clear Asks

 Personal Perspective

 Context

 Goal/Value

 What should you consider for a perfect response? Select all that apply

 It should beat the State Of The Art (SOTA) Model

 Having perfect spelling and grammar

 To be alligned with the task type category

 Maintaining a clear format

What is the most important thing to consider when working with multiturns?

To maintain continuity, they should build off context from previous prompts
and responses
Here are the categories, please take a look. Always keep them in your notes
while doing the tasks.

Task Categories

Examples
Task Categories and Examples

Task Categories
Examples

Need Help?

Perfect Task

Take this example as a future reference to generate good prompts and


responses.

Task Category: Code Refactoring

Prompt: I'm working on an application for a grocery store, I have this


program:

import Foundation
print("Enter the amount to pay: ", terminator: "")

if let input = readLine(), let amount = Double(input) {

let amountCoins = Int(round((amount - Double(Int(amount))) * 100))

var remainingCoins = amountCoins

let quarters = remainingCoins / 25

remainingCoins %= 25

let dimes = remainingCoins / 10

remainingCoins %= 10

let nickels = remainingCoins / 5

remainingCoins %= 5

let pennies = remainingCoins

print("The change is:")

print("25 cent coins: \(quarters)")

print("10 cent coins: \(dimes)")

print("5 cent coins: \(nickels)")

print("1 cent coins: \(pennies)")

} else {

print("Invalid input.")

}
This program gives change for cents of an amount, in coins of 25, 10, 5, and
1 cents. I want an improved version that is modularized and simple to add
other coin values such as 50 cents coins and has appropriate comments in
each section of the code.

Response:

The following code is an improved version of the program:

```swift

import Foundation

/// Calculate the minimum number of coins needed for a given amount in
cents with a list of coin values as constants.

///

/// - Parameters:

/// - amountCents (Int): The amount in cents to be converted into coins.

/// - Returns:

/// - Array of tuples: An array where each tuple contains a coin value and the
number of such coins used.

func coinsCents(amountCents: Int, coinsValue: [Int]) -> [(Int, Int)] {

// List with the number of each type of coin

var numberCoins: [Int] = []

var remainingAmount = amountCents

for coin in coinsValue {

// Calculate the number of coins of this type

let result = remainingAmount / coin

if result > 0 {

// Add the number of coins to the list


numberCoins.append(result)

// Calculate the remaining amount of cents

remainingAmount = remainingAmount % coin

} else {

// Add zero if no coins of this type are used

numberCoins.append(result)

// Create an array of tuples

let coinsNumbers = Array(zip(coinsValue, numberCoins))

return coinsNumbers

/// Display the coin distribution.

///

/// - Parameters:

/// - change (Array of tuples): An array of tuples where each tuple contains a
coin value and the number of such coins used.

func displayChange(change: [(Int, Int)]) {

print("The change is:")

for (value, number) in change {

print("For \(value) cent coins is \(number)")

}
// Prompt the user to enter the amount to pay and calculate the amount of
cents

print("Enter the amount to pay: ", terminator: "")

if let amountInput = readLine(), let amount = Double(amountInput) {

let amountCents = Int(round((amount - Double(Int(amount))) * 100))

// List of coin values, including 50 cents

let coinsValue = [50, 25, 10, 5, 1]

// Get the coin distribution and show the result

let change = coinsCents(amountCents: amountCents, coinsValue:


coinsValue)

displayChange(change: change)

} else {

print("Invalid input.")

```

The code has a function `coins_cents` that allows for a more efficient
calculation of the number of coins required for each type so that the number
of coins is the minimum possible. The code structure is adjusted to have a
main block with a call to the function and a practical display of the result. It
has comments on the relevant lines as well as docstrings in the functions.

Dividing the Prompt into the perfect prompt structure.

Clear Asks:

• Modularize the existing program.

• Add functionality to easily include other coin values, such as 50-cent coins.

• Add appropriate comments to each section of the code.


Personal Perspective:

• The individual is working on an application for a grocery store.

• They are seeking to improve the existing program to make it more flexible
and maintainable.

Context:

• The current program calculates change in coins for an entered amount in


cents, using 25, 10, 5, and 1-cent coins.

• The program needs to be improved to support additional coin values and to


be more modular.

Goal / Value:

• The desired outcome is a modular and flexible program that can easily
incorporate additional coin values, such as 50-cent coins.

• The program should be well-documented with appropriate comments for


better readability and maintainability.

Evaluating the response:

1. Instruction Following: The response follows the given instructions


precisely and provides a modularized and commented version of the
code, including the addition of new coin values such as 50 cents.

2. Concision:The response is very concise, providing only necessary


information without unnecessary details. Each section is clear and to
the point.

3. Truthfulness: The response is accurate and correct. The provided


code and explanation are correct and relevant to the given prompt

4. Harmfulness: This response does not contain any harmful content. It


is focused on improving and modularizing code, which is a positive and
helpful activity.
5. Satisfaction: The response is highly satisfying as it addresses all the
requirements effectively. It provides clear, actionable solutions and is
well-organized and easy to understand.

Need Help?

Strategies to beat SOTA

All levels can be considered simultaneously; they are not mutually exclusive.
Need Help?

Reviewing Basics for Swift

Key Concepts
1. Constants and Variables: Constants (let) and variables (var) store
values. Constants cannot be changed once set, whereas variables can.

2. Data Types: Swift uses type inference and also allows explicit type
declarations for clarity

3. Basic Operators: Operators include arithmetic (+, -), comparison


(==, !=), and logical (&&, ||).

4. Strings and Characters: Strings are sequences of characters, and


Swift provides powerful string manipulation capabilities.

5. Control Flow: Control flow statements (if, switch, loops) determine


the execution path based on conditions.

6. Optionals: Optionals (?) represent variables that can hold a value or


nil, indicating the absence of a value.

Best Practices

1. Type Safety: Swift’s type system helps prevent errors by ensuring


that values match the expected types.

2. Readability: Writing clear and concise code with meaningful variable


names and comments enhances maintainability.

3. Error Handling: Using optionals and error handling allows the


program to handle unexpected conditions gracefully.

Practical Techniques

1. Declaring Variables: Use let for constants and var for variables.

2. String Interpolation: String interpolation allows embedding variables


and expressions in strings.

3. Looping Constructs: Loops (for-in, while) enable iteration over


collections or execution of repetitive tasks.

4. Optional Unwrapping: Optional binding safely extracts values from


optional.

For more details, you can visit the Swift Programming Language
Documentation:
 Swift Programming Language (6.0 beta)

 Articles about Swift.

 iOS Insights

 Swift Books

No MacBook? No Problem!

Focus on building Swift scripts and test your code using these tools:

 Replit: A fantastic, free interface for coding.

 Programiz: A simpler interface but equally useful.

Happy coding!

Task Interface

While we know that each project looks different, this section showcases
thetasking interface and the steps to follow.

1) When tasking as an attempter, the first section is for reminders/info for


your specific project. Please note: as we progress, the content in these
sections may change.
2) Select the sub category task with the drop-down menu that you want to
do in SWIFT program language.
3) Next, you have the Construct a Prompt Section. Much like the previous
section, useful project-related information is shown here.

4) After the prompt section, your response section follows right after. Here
you need to make sure that the response is original, creative, and adhering
to the task category and responding to the prompt.Before the next step,
please select Get feedback, and do the proper modifications
5) Once you have taken the time to craft your response, you may hit finish
editing. Depending on your project, you may either need to write another
turn before submitting!

Evaluation Criteria - General Rubric


Need Help?

Evaluation Criteria - Coding Rubric


🐝Project Bee Common Errors🐝

Course Overview

This course aims to help you identify and correct common errors.

Read them carefully to improve tasks and maintain good practices!

Code Execution:

Indentation Issues

🚨DISCLAIMER🚨

ALL TASKS SHOULD BE IN SWIFT LANGUAGE

Common Errors

Incorrect indentation can lead to syntax errors or unexpected behavior,


making it crucial for taskers to follow consistent indentation practices.

Best Practices

 Code (including inline code and code blocks) should be in standard


Markdown format.

 Inline code should be enclosed by ` (a single backtick), such as


`print("hello)`.

 Code blocks should be enclosed by ``` (triple backticks) with language


name (e.g., ```swift) whenever language name is available.

 Swift 5

Lists

They can be displayed in a numbered list or a bulleted list.

Tables

They should be in a markdown format:

Headers
Headers should be used to organize content or establish a hierarchy of
information.

Highlights

Only bold text should be used for highlighting, no italics or underlining.

Coding Style

 Swift 5

Prompt Design:

Lack of complexity

Common Error

The prompt is too basic, resulting in solutions that do not fully address the
task's complexity.

Best Practices

Create prompts that are more detailed and complex. Employ advanced
problem-solving techniques and consider multiple approaches to ensure the
task is addressed comprehensively. This involves incorporating specific
requirements within the prompt to encourage a more thorough and in-depth
response.

Too many constraints and/or requirements

Common Error

Adding too many constraints to a prompt does not necessarily increase its
complexity. Instead, it results in a very specific task that does not contribute
effectively to training the model.

Best Practices

The goal should be to make the prompt challenging enough to push the
model's capabilities without overwhelming it with excessively specific
requirements:

 Balance Constraints: Include enough constraints to guide the


response without making the task overly specific.
 Challenge the Model: Design prompts that aim to test the model's
problem-solving abilities. The prompts should be challenging enough to
highlight areas where the model may struggle.

 Iterative Refinement: Continuously refine prompts based on


feedback and results. If a prompt is too easy or too specific, adjust the
constraints to strike the right balance.

Adding these best practices, ensures the prompt remains broad enough to be
useful for training while still presenting a meaningful challenge.

Need Help?

Response Design:

Verbosity

Common Error

There are multiple sentences to explain concepts that are possible within a
sentence or two.

Best Practices

It's important to avoid overly verbose responses. Explanations, assumptions,


and conclusions should be clear and concise, providing necessary details
without including very basic steps, unless explicitly required by the
instructions.

Keeping responses clear and to the point ensures that the message is
effectively conveyed and understood.

Lack of details

Common Error

 Provide responses that are too simplistic and do not address the full
scope or complexity of the prompt.

 Omitting important details or steps that are crucial for understanding


or solving the task.
Best Practices

 Ensure that the response includes all necessary details and addresses
the prompt comprehensively.

 Break down the task into detailed steps and ensure each step is
thoroughly explained.

Need Help?

Instruction Following:

Incomplete Explanation

Common Error

Provide responses that do not fully explain the reasoning or process behind
the solution.

Best Practices

Include comprehensive explanations for each step and justify why certain
methods or approaches are used if needed/asked in the prompt.

Problem Reflection

Following instructions accurately is essential in any task, particularly when


responding to prompts or questions. Failing to address specific prompts can
result in incomplete or irrelevant answers, leading to confusion.

Common Error

Specifically for this subcategory, it is necessary to have more than one


approach to the task.

Best Practices

Providing multiple approaches not only demonstrates a deeper


understanding of the problem but also offers alternatives that may be more
suitable for different contexts or constraints.

Need Help?

Grammar:

Typos

Common Error
Typos can undermine the credibility of a document and lead to
misunderstandings. It could also be one of the reasons why the code doesn't
compile correctly.

Best Practices

Proofreading:

 Always proofread your work before submission. Read through your


document multiple times to catch any typos or errors.

Use Spell Check Tools:

 Use built-in spell check tools in word processors or code editors to


automatically detect and highlight spelling errors.

 Install additional extensions that provide enhanced spell check


capabilities for specific programming languages or writing styles.

Code Reviews:

 Use code review tools and platforms that provide integrated discussion
and annotation features.
 Don't forget!
 By following these best practices, you ensure that your task is well-

crafted and effective for model training.

 Don't forget to adhere to the subcategory, check for any grammar or

spelling mistakes, and make sure you follow the instructions according

to what the task is asking!

 🐝

You might also like